From: Argyrios Kyrtzidis Date: Thu, 4 Nov 2010 08:48:52 +0000 (+0000) Subject: Don't be so eager to replace UsingDecls in a DeclContext's lookup table; X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c80117e7971c34088f3e254c849ec3a40205d2c3;p=clang 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 --- diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index ca963ad7e5..c6c7649bda 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 5148ed5bcc..7b4da9d50d 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(); +}