From 151e9e51f98174052f23abce842358bcd9a13833 Mon Sep 17 00:00:00 2001 From: Argiris Kirtzidis Date: Thu, 4 Nov 2010 08:48:52 +0000 Subject: [PATCH] Don't be so eager to replace UsingDecls in a DeclContext's lookup table; 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 | 4 ++++ test/SemaCXX/using-decl-templates.cpp | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index ca963ad7e..c6c7649bd 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -732,6 +732,10 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD) const { return cast(this)->getTargetDecl() == cast(OldD)->getTargetDecl(); + if (isa(this) && isa(OldD)) + return cast(this)->getTargetNestedNameDecl() == + cast(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. diff --git a/test/SemaCXX/using-decl-templates.cpp b/test/SemaCXX/using-decl-templates.cpp index 5148ed5bc..7b4da9d50 100644 --- a/test/SemaCXX/using-decl-templates.cpp +++ b/test/SemaCXX/using-decl-templates.cpp @@ -45,3 +45,21 @@ namespace test0 { template struct E; } + +// PR7896 +namespace PR7896 { +template struct Foo { + int k (float); +}; +struct Baz { + int k (int); +}; +template struct Bar : public Foo, Baz { + using Foo::k; + using Baz::k; + int foo() { + return k (1.0f); + } +}; +template int Bar::foo(); +} -- 2.11.4.GIT