[cfe-commits] r65373 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.def lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp test/Sema/function-redecl.c

Douglas Gregor dgregor at apple.com
Tue Feb 24 08:23:44 PST 2009


On Feb 23, 2009, at 11:31 PM, Chris Lattner wrote:
> On Feb 23, 2009, at 8:26 PM, Douglas Gregor wrote:
>
>> Author: dgregor
>> Date: Mon Feb 23 22:26:15 2009
>> New Revision: 65373
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=65373&view=rev
>> Log:
>> In C, when we see a function declaration within a local scope, export
>> that declaration to global scope so that it can be found from other
>> scopes. This allows us to diagnose redeclaration errors for external
>> declarations across scopes. We also warn when name lookup finds such
>> an out-of-scope declaration. This is part of <rdar://problem/ 
>> 6127293>;
>> we'll also need to do the same thing for variables.
>
> Very nice Doug, thanks for working on this!
>
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Feb 23 22:26:15 2009
>> @@ -2033,6 +2033,58 @@
>>      InvalidDecl = true;
>>    }
>>  }
>> +
>> +  if (!getLangOptions().CPlusPlus && CurContext- 
>> >isFunctionOrMethod()) {
>
> Please pull the body of this if into its own method.  Doing this  
> forces you to pick a name for it :), which aids readability and  
> makes the main control flow of this method easier to follow.  Thanks!


That'll be part of "doing the same thing for variables" :)

	- Doug



More information about the cfe-commits mailing list