]> granicus.if.org Git - clang/commitdiff
Don't be so eager to replace UsingDecls in a DeclContext's lookup table;
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 4 Nov 2010 08:48:52 +0000 (08:48 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 4 Nov 2010 08:48:52 +0000 (08:48 +0000)
check that the TargetNestedNameDecl is the same first.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118239 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/SemaCXX/using-decl-templates.cpp

index ca963ad7e599832236f963b94bd5899c6b56396d..c6c7649bdac1d5f57341b5c20224beba0ba29ff6 100644 (file)
@@ -732,6 +732,10 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD) const {
     return cast<UsingShadowDecl>(this)->getTargetDecl() ==
            cast<UsingShadowDecl>(OldD)->getTargetDecl();
 
+  if (isa<UsingDecl>(this) && isa<UsingDecl>(OldD))
+    return cast<UsingDecl>(this)->getTargetNestedNameDecl() ==
+           cast<UsingDecl>(OldD)->getTargetNestedNameDecl();
+
   // For non-function declarations, if the declarations are of the
   // same kind then this must be a redeclaration, or semantic analysis
   // would not have given us the new declaration.
index 5148ed5bcc7152356645386bff815c9d5dfc407a..7b4da9d50d032bb47067fa99b8a0b602000495c6 100644 (file)
@@ -45,3 +45,21 @@ namespace test0 {
 
   template struct E<int>;
 }
+
+// PR7896
+namespace PR7896 {
+template <class T> struct Foo {
+  int k (float);
+};
+struct Baz {
+  int k (int);
+};
+template <class T> struct Bar : public Foo<T>, Baz {
+  using Foo<T>::k;
+  using Baz::k;
+  int foo() {
+    return k (1.0f);
+  }
+};
+template int Bar<int>::foo();
+}