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

Chris Lattner clattner at apple.com
Mon Feb 23 23:31:08 PST 2009


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!

-Chris




More information about the cfe-commits mailing list