[cfe-commits] r50538 - /cfe/trunk/lib/Sema/SemaDecl.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Fri May 2 14:36:55 PDT 2008


Neil Booth wrote:
> You've got to respect scope.  Clang now accepts the following invalid code:
>
> void foo (void) { g(); } int (*f)(void) = g;
>
> $ clang /tmp/bug.c -std=c90 -pedantic-errors
>
> /tmp/bug.c:3:3: warning: implicit declaration of function 'g'
>   g();
>   ^
> 1 diagnostic generated.
>
> Compare with:
>
> $ cfe /tmp/bug.c --c90
> "/tmp/bug.c", line 1: warning: implicitly declaring "extern int g ();"
>     at block scope
> void foo (void) { g(); } int (*f)(void) = g;
>                   ^
> "/tmp/bug.c", line 1: error: identifier "g" is not defined
> void foo (void) { g(); } int (*f)(void) = g;
>                                           ^
>
> 1 error found compiling "/tmp/bug.c".
>   

Out of curiosity, how is this accepted ?:

void foo (void) { g(); }
int g;

If you respect scope then you shouldn't report a redeclaration error, is 
this correct ?

As a side note, just to make sure it's clear enough, my commit didn't 
cause this behavior on clang, it was already working this way.
The commit just satisfied an assertion, it didn't make a difference in 
how implicitly defined functions are handled.


-Argiris



More information about the cfe-commits mailing list