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 292820b..549f87b 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -233,7 +233,7 @@
   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 789fe3d..fda2b9e 100644
--- a/test/SemaTemplate/instantiate-static-var.cpp
+++ b/test/SemaTemplate/instantiate-static-var.cpp
@@ -92,3 +92,26 @@
 void MyTest3() {
    Y3().Foo(X3<SizeOf<char>::value>());
 }
+
+namespace PR6449 {
+  template<typename T>    
+  struct X0  {
+    static const bool var = false;
+  };
+
+  template<typename T>
+  const bool X0<T>::var;
+
+  template<typename T>
+  struct X1 : public X0<T> {
+    static const bool var = false;
+  };
+
+  template<typename T>      
+  const bool X1<T>::var;
+
+  template class X0<char>;
+  template class X1<char>;
+
+}
+