From: Eli Friedman Date: Tue, 20 Aug 2013 00:39:40 +0000 (+0000) Subject: Fix name lookup with dependent using decls. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13b572c9e84729b4bd5f00d0f1452a4b93211cde;p=clang Fix name lookup with dependent using decls. We previously mishandled UnresolvedUsingValueDecls in NamedDecl::declarationReplaces, which caused us to forget decls when there are multiple dependent using decls for the same name. Fixes PR16936. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188737 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 9562879de6..1c2ead0ee5 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -1353,6 +1353,15 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD) const { cast(OldD)->getQualifier()); } + if (isa(this) && + isa(OldD)) { + ASTContext &Context = getASTContext(); + return Context.getCanonicalNestedNameSpecifier( + cast(this)->getQualifier()) == + Context.getCanonicalNestedNameSpecifier( + cast(OldD)->getQualifier()); + } + // A typedef of an Objective-C class type can replace an Objective-C class // declaration or definition, and vice versa. if ((isa(this) && isa(OldD)) || diff --git a/test/SemaTemplate/instantiate-using-decl.cpp b/test/SemaTemplate/instantiate-using-decl.cpp index 1bfcb7a865..a6a4ea0e0f 100644 --- a/test/SemaTemplate/instantiate-using-decl.cpp +++ b/test/SemaTemplate/instantiate-using-decl.cpp @@ -80,3 +80,27 @@ namespace test3 { b.f1(); } } + +namespace PR16936 { + // Make sure both using decls are properly considered for + // overload resolution. + template struct A { + void access(int); + }; + template struct B { + void access(); + }; + template struct X : public A, public B { + using A::access; + using B::access; + + void f() { + access(0); + } + }; + + void f() { + X x; + x.f(); + } +}