Author: rsmith Date: Fri Feb 26 20:36:43 2016 New Revision: 262105 URL: http://llvm.org/viewvc/llvm-project?rev=262105&view=rev Log: Fix bug in using shadow decl checking: a using shadow decl should not conflict with a prior UsingDecl -- those should not even really be found by the lookup here, except that we use the same lookup results for two different checks, and the other check needs them.
This happens to work in *almost all* cases, because either the lookup results list the UsingDecl first (and the NonTag result gets replaced by something else) or because the problematic declaration is a function (which causes us to use different logic to detect conflicts). This can also be triggered from a state only reachable through modules (where the name lookup results can contain multiple UsingDecls in the same scope). Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/test/SemaCXX/using-decl-1.cpp Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=262105&r1=262104&r2=262105&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Feb 26 20:36:43 2016 @@ -7796,6 +7796,12 @@ bool Sema::CheckUsingShadowDecl(UsingDec for (LookupResult::iterator I = Previous.begin(), E = Previous.end(); I != E; ++I) { NamedDecl *D = (*I)->getUnderlyingDecl(); + // We can have UsingDecls in our Previous results because we use the same + // LookupResult for checking whether the UsingDecl itself is a valid + // redeclaration. + if (isa<UsingDecl>(D)) + continue; + if (IsEquivalentForUsingDecl(Context, D, Target)) { if (UsingShadowDecl *Shadow = dyn_cast<UsingShadowDecl>(*I)) PrevShadow = Shadow; Modified: cfe/trunk/test/SemaCXX/using-decl-1.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-decl-1.cpp?rev=262105&r1=262104&r2=262105&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/using-decl-1.cpp (original) +++ cfe/trunk/test/SemaCXX/using-decl-1.cpp Fri Feb 26 20:36:43 2016 @@ -338,3 +338,26 @@ struct B : A { enum { X = sizeof(field) }; }; } + +namespace tag_vs_var { + namespace N { + struct X {}; + + struct Y {}; + int Y; + + int Z; + } + using N::X; + using N::Y; + using N::Z; + + namespace N { + int X; + + struct Z {}; + } + using N::X; + using N::Y; + using N::Z; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits