From 79e31db9a99e8b1e8af740f5b689581c55bdbc9d Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 1 Mar 2010 19:11:54 +0000 Subject: [PATCH] When looking for a redeclaration of a static variable, only look for redeclarations. Fixes PR6449 llvm-svn: 97478 --- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 +- .../SemaTemplate/instantiate-static-var.cpp | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 292820b821c4..549f87b2cadb 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -233,7 +233,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { bool Redeclaration = false; // FIXME: having to fake up a LookupResult is dumb. LookupResult Previous(SemaRef, Var->getDeclName(), Var->getLocation(), - Sema::LookupOrdinaryName); + Sema::LookupOrdinaryName, Sema::ForRedeclaration); if (D->isStaticDataMember()) SemaRef.LookupQualifiedName(Previous, Owner, false); SemaRef.CheckVariableDeclaration(Var, Previous, Redeclaration); diff --git a/clang/test/SemaTemplate/instantiate-static-var.cpp b/clang/test/SemaTemplate/instantiate-static-var.cpp index 789fe3db872e..fda2b9ea306b 100644 --- a/clang/test/SemaTemplate/instantiate-static-var.cpp +++ b/clang/test/SemaTemplate/instantiate-static-var.cpp @@ -92,3 +92,26 @@ struct SizeOf { void MyTest3() { Y3().Foo(X3::value>()); } + +namespace PR6449 { + template + struct X0 { + static const bool var = false; + }; + + template + const bool X0::var; + + template + struct X1 : public X0 { + static const bool var = false; + }; + + template + const bool X1::var; + + template class X0; + template class X1; + +} +