> You use this to get suggested corrections when things don't compile.
It repeatedly says that the aim is to fix errors. Assuming, however, that it is intended to give better error messages, here is the output of Clang on the input C program given as an example:
$ cc gupta.c
gupta.c:3:5: warning: incompatible redeclaration of library function 'pow'
[-Wincompatible-library-redeclaration]
int pow(int a, int b);
^
gupta.c:3:5: note: 'pow' is a builtin with type 'double (double, double)'
gupta.c:14:23: error: function definition is not allowed here
int pow(int a, int b){
^
gupta.c:18:14: error: expected ';' at end of declaration
return res;}
^
;
gupta.c:18:14: error: expected '}'
gupta.c:4:11: note: to match this '{'
int main(){
^
1 warning and 3 errors generated.
It identifies the problematic line of the program code better than gcc. The function declaration within main is not legal. I tried this with the gcc compiler and did not get the error above. Running "indent" on the code would have revealed the problems:
$ indent < gupta.c
/INDENT Error@18: Stuff missing from end of file */
A simple count of braces, { and }, would also have revealed the problem.
A simple way to get suggestions is to take your finite state machine (that consumes tokens) to a special error state and just analyze what got you there. You'll pick up quite a lot of errors.
It repeatedly says that the aim is to fix errors. Assuming, however, that it is intended to give better error messages, here is the output of Clang on the input C program given as an example:
It identifies the problematic line of the program code better than gcc. The function declaration within main is not legal. I tried this with the gcc compiler and did not get the error above. Running "indent" on the code would have revealed the problems:$ indent < gupta.c
/INDENT Error@18: Stuff missing from end of file */
A simple count of braces, { and }, would also have revealed the problem.