[cfe-commits] r49621 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/DeclBase.h include/clang/AST/Type.h lib/AST/ASTContext.cpp lib/Sema/IdentifierResolver.cpp lib/Sema/IdentifierResolver.h lib/Sema/SemaDecl.cpp lib/Sema/SemaType.cpp test/Sema/class-names.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Sun Apr 13 17:10:52 PDT 2008


Douglas Gregor wrote:
> @@ -113,6 +114,25 @@
>    } else
>      IDI = toIdDeclInfo(Ptr);
>  
> +  // C++ [basic.scope]p4:
> +  //   -- exactly one declaration shall declare a class name or
> +  //   enumeration name that is not a typedef name and the other
> +  //   declarations shall all refer to the same object or
> +  //   enumerator, or all refer to functions and function templates;
> +  //   in this case the class name or enumeration name is hidden.
> +  if (isa<TagDecl>(D)) {
> +    // We are pushing the name of a tag (enum or class).
> +    IdDeclInfo::ShadowedIter TopIter = IDI->shadowed_end() - 1;
>   

The IdDeclInfo could be empty. Such a case could occur if two decls are 
added and later removed because their scope exited.
So, to be safe:

+  if (isa<TagDecl>(D) && IDI->shadowed_end() != IDI->shadowed_begin() ) {


-Argiris




More information about the cfe-commits mailing list