[cfe-commits] r97478 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaTemplate/instantiate-static-var.cpp

Douglas Gregor dgregor at apple.com
Mon Mar 1 11:11:54 PST 2010


Author: dgregor
Date: Mon Mar  1 13:11:54 2010
New Revision: 97478

URL: http://llvm.org/viewvc/llvm-project?rev=97478&view=rev
Log:
When looking for a redeclaration of a static variable, only look for redeclarations. Fixes PR6449

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=97478&r1=97477&r2=97478&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Mar  1 13:11:54 2010
@@ -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);

Modified: cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp?rev=97478&r1=97477&r2=97478&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp Mon Mar  1 13:11:54 2010
@@ -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>;
+
+}
+





More information about the cfe-commits mailing list