From: Douglas Gregor Date: Mon, 1 Mar 2010 19:11:54 +0000 (+0000) Subject: When looking for a redeclaration of a static variable, only look for redeclarations... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=449d0a829007ea654912098e6a73134a2c529d61;p=clang When looking for a redeclaration of a static variable, only look for redeclarations. Fixes PR6449 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97478 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 292820b821..549f87b2ca 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/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/test/SemaTemplate/instantiate-static-var.cpp b/test/SemaTemplate/instantiate-static-var.cpp index 789fe3db87..fda2b9ea30 100644 --- a/test/SemaTemplate/instantiate-static-var.cpp +++ b/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; + +} +