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

Douglas Gregor dgregor at apple.com
Mon Jul 27 10:43:46 PDT 2009


Author: dgregor
Date: Mon Jul 27 12:43:39 2009
New Revision: 77211

URL: http://llvm.org/viewvc/llvm-project?rev=77211&view=rev
Log:
When instantiating a variable without an initializer, call
ActOnUninitializedDecl.

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=77211&r1=77210&r2=77211&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Jul 27 12:43:39 2009
@@ -146,9 +146,8 @@
     else
       SemaRef.AddInitializerToDecl(Sema::DeclPtrTy::make(Var), move(Init),
                                    D->hasCXXDirectInitializer());
-  } else {
-    // FIXME: Call ActOnUninitializedDecl? (Not always)
-  }
+  } else if (!Var->isStaticDataMember() || Var->isOutOfLine())
+    SemaRef.ActOnUninitializedDecl(Sema::DeclPtrTy::make(Var), false);
 
   // Link instantiations of static data members back to the template from
   // which they were instantiated.

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=77211&r1=77210&r2=77211&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp Mon Jul 27 12:43:39 2009
@@ -16,3 +16,25 @@
 };
 
 Y<float> fy; // expected-note{{in instantiation of template class 'class Y<float>' requested here}}
+
+
+// out-of-line static member variables
+
+template<typename T>
+struct Z {
+  static T value;
+};
+
+template<typename T>
+T Z<T>::value; // expected-error{{no matching constructor}}
+
+struct DefCon {};
+
+struct NoDefCon { 
+  NoDefCon(const NoDefCon&);
+};
+
+void test() {
+  DefCon &DC = Z<DefCon>::value;
+  NoDefCon &NDC = Z<NoDefCon>::value; // expected-note{{instantiation}}
+}
\ No newline at end of file





More information about the cfe-commits mailing list