]> granicus.if.org Git - clang/commitdiff
Fix name lookup with dependent using decls.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 20 Aug 2013 00:39:40 +0000 (00:39 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 20 Aug 2013 00:39:40 +0000 (00:39 +0000)
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

lib/AST/Decl.cpp
test/SemaTemplate/instantiate-using-decl.cpp

index 9562879de6a4f09864e4c43ab38a9f01205af84d..1c2ead0ee59722b6c18e40e26ad4cb6f2ea5eca6 100644 (file)
@@ -1353,6 +1353,15 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD) const {
                                         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)) ||
index 1bfcb7a86508eb55dc45884773f369c3ff28c6c5..a6a4ea0e0f6de208d29163c36da08f49c5758bcd 100644 (file)
@@ -80,3 +80,27 @@ namespace test3 {
     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();
+  }
+}