[PATCH] Do not add enums to prototype scope in C++ modes.

Peter Collingbourne peter at pcc.me.uk
Fri Feb 21 18:55:33 PST 2014

Comment at: lib/Sema/SemaDecl.cpp:12955-12956
@@ -12954,4 +12954,4 @@
   // it needs to go into the function scope.
-  if (InFunctionDeclarator)
+  if (!getLangOpts().CPlusPlus && InFunctionDeclarator)
Richard Smith wrote:
> In `ActOnTag` we have this condition:
>   if (S->isFunctionPrototypeScope() && !getLangOpts().CPlusPlus &&
>       InFunctionDeclarator && Name)
> Is there a good reason for these to be different?
> (I'm not particularly happy that `InFunctionDeclarator` is nonzero in the case where we've switched out of function declarator scope -- can you also update the comment in Sema.h to indicate that this value may be inaccurate in C++?)
> Is there a good reason for these to be different?

After digging into this some more, I think this logic only needs to be in ActOnTag since it handles all tag types. I was also able to simplify the logic by relying only on scopes to determine when we are in prototype scope and getting rid of InFunctionDeclarator.


More information about the cfe-commits mailing list