[cfe-commits] r50538 - /cfe/trunk/lib/Sema/SemaDecl.cpp
Neil Booth
neil at daikokuya.co.uk
Fri May 2 10:09:18 PDT 2008
Argiris Kirtzidis wrote:-
>
> Neil Booth wrote:
>>> Author: akirtzidis
>>> Date: Thu May 1 16:04:16 2008
>>> New Revision: 50538
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=50538&view=rev
>>> Log:
>>> Implicitly defined functions were getting the DeclContext of the function where they appeared, causing the bug: http://llvm.org/bugs/show_bug.cgi?id=2266.
>>> Fix it by making implicitly defined functions get the DeclContext of translation unit.
>>>
>>
>> Does this give them local or global scope? They should only have local
>> scope; it sounds like you're making them global.
>>
>
> I don't quite understand what you mean. Given:
>
> void f1() {
> g(); // #1
> }
>
> void f2() {
> g(); // #2
> }
>
> int g() { // #3
> ....
> }
>
> Aren't both 'g' references supposed to refer to the same function, later
> defined (on #3) ?
>
> In any case, clang was already assigning implicitly defined functions to
> the translation unit scope.
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".
Neil.
More information about the cfe-commits
mailing list