r188737 - Fix name lookup with dependent using decls.

Eli Friedman eli.friedman at gmail.com
Mon Aug 19 17:39:40 PDT 2013


Author: efriedma
Date: Mon Aug 19 19:39:40 2013
New Revision: 188737

URL: http://llvm.org/viewvc/llvm-project?rev=188737&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/test/SemaTemplate/instantiate-using-decl.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=188737&r1=188736&r2=188737&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Mon Aug 19 19:39:40 2013
@@ -1353,6 +1353,15 @@ bool NamedDecl::declarationReplaces(Name
                                         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)) ||

Modified: cfe/trunk/test/SemaTemplate/instantiate-using-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-using-decl.cpp?rev=188737&r1=188736&r2=188737&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-using-decl.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-using-decl.cpp Mon Aug 19 19:39:40 2013
@@ -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();
+  }
+}





More information about the cfe-commits mailing list