[cfe-commits] r86508 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/CodeGenCXX/instantiate-init-list.cpp

Eli Friedman eli.friedman at gmail.com
Sun Nov 8 19:59:27 PST 2009


Author: efriedma
Date: Sun Nov  8 21:59:26 2009
New Revision: 86508

URL: http://llvm.org/viewvc/llvm-project?rev=86508&view=rev
Log:
Add hack to make the given testcase work.  As far as I can tell, this change is
reasonably safe, but it doesn't seem like the right solution.


Added:
    cfe/trunk/test/CodeGenCXX/instantiate-init-list.cpp
Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=86508&r1=86507&r2=86508&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Sun Nov  8 21:59:26 2009
@@ -188,11 +188,13 @@
       Var->setInvalidDecl();
     else if (!D->getType()->isDependentType() &&
              !D->getInit()->isTypeDependent() &&
-             !D->getInit()->isValueDependent()) {
+             !D->getInit()->isValueDependent() &&
+             !isa<InitListExpr>(D->getInit())) {
       // If neither the declaration's type nor its initializer are dependent,
       // we don't want to redo all the checking, especially since the
       // initializer might have been wrapped by a CXXConstructExpr since we did
       // it the first time.
+      // FIXME: The InitListExpr handling here is a hack!
       Var->setInit(SemaRef.Context, Init.takeAs<Expr>());
     }
     else if (ParenListExpr *PLE = dyn_cast<ParenListExpr>((Expr *)Init.get())) {

Added: cfe/trunk/test/CodeGenCXX/instantiate-init-list.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/instantiate-init-list.cpp?rev=86508&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenCXX/instantiate-init-list.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/instantiate-init-list.cpp Sun Nov  8 21:59:26 2009
@@ -0,0 +1,13 @@
+// RUN: clang-cc %s -emit-llvm-only -verify
+
+struct F {
+  void (*x)();
+};
+void G();
+template<class T> class A {
+  A();
+};
+template<class T> A<T>::A() {
+  static F f = { G };
+}
+A<int> a;





More information about the cfe-commits mailing list