http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57205

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-05-08
                 CC|                            |manu at gcc dot gnu.org
            Summary|unfinished function         |for unfinished function
                   |declaration and inclusion   |declaration, recover by
                   |of assert.h causes compiler |skipping until matched
                   |errors                      |parenthesis and report
                   |                            |non-matched parenthesis
     Ever Confirmed|0                           |1

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2013-05-08 
11:15:00 UTC ---
I don't think GCC can do much better, since when reading a header file, the
function declaration does not need to be complete, so:

int foo(int *file,
#include "something.h"
);

can be correct depending on the contents of something.h.

Clang shows:

/usr/include/assert.h:71:1: error: invalid storage class specifier in function
declarator
extern void __assert_fail (__const char *__assertion, __const char *__file,
^
/usr/include/assert.h:73:44: error: expected ')'
     __THROW __attribute__ ((__noreturn__));
                                           ^
/home/manuel/test.c:1:8: note: to match this '('
int foo(int *file,
       ^

which is very similar to GCC.

GCC could recover better by skipping everything up to the first non-matched
parenthesis, and then report the location of the non-matched parenthesis when
not found, like Clang does. 

I am not sure what heuristics Clang uses to decide when to skip, but being in a
different file or finding something like "extern" is definitely a good moment
to think that something went terribly wrong and skip the whole function.

Reply via email to