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 9562879..1c2ead0 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -1353,6 +1353,15 @@
cast<UsingDecl>(OldD)->getQualifier());
}
+ if (isa<UnresolvedUsingValueDecl>(this) &&
+ isa<UnresolvedUsingValueDecl>(OldD)) {
+ ASTContext &Context = getASTContext();
+ return Context.getCanonicalNestedNameSpecifier(
+ cast<UnresolvedUsingValueDecl>(this)->getQualifier()) ==
+ Context.getCanonicalNestedNameSpecifier(
+ cast<UnresolvedUsingValueDecl>(OldD)->getQualifier());
+ }
+
// A typedef of an Objective-C class type can replace an Objective-C class
// declaration or definition, and vice versa.
if ((isa<TypedefNameDecl>(this) && isa<ObjCInterfaceDecl>(OldD)) ||
diff --git a/test/SemaTemplate/instantiate-using-decl.cpp b/test/SemaTemplate/instantiate-using-decl.cpp
index 1bfcb7a..a6a4ea0 100644
--- a/test/SemaTemplate/instantiate-using-decl.cpp
+++ b/test/SemaTemplate/instantiate-using-decl.cpp
@@ -80,3 +80,27 @@
b.f1();
}
}
+
+namespace PR16936 {
+ // Make sure both using decls are properly considered for
+ // overload resolution.
+ template<class> struct A {
+ void access(int);
+ };
+ template<class> struct B {
+ void access();
+ };
+ template<class CELL> struct X : public A<CELL>, public B<CELL> {
+ using A<CELL>::access;
+ using B<CELL>::access;
+
+ void f() {
+ access(0);
+ }
+ };
+
+ void f() {
+ X<int> x;
+ x.f();
+ }
+}