[PATCH] [Patch] Fix for assertion when incomplete array type is used as template param

Richard Smith richard at metafoo.co.uk
Wed Oct 16 12:50:58 PDT 2013



================
Comment at: llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:367-379
@@ -366,1 +366,15 @@
 
+  if (D->getInit() && !InstantiatingVarTemplate) {
+    const Expr* Arg = D->getInit();
+    const InitListExpr *ILE = dyn_cast<InitListExpr>(Arg);
+    if(!ILE || (ILE && !ILE->isStringLiteralInit() && ILE->getNumInits() == 0 )) {
+      if (D->getType()->isIncompleteType() || D->getType()->isIncompleteOrObjectType() ) {
+        if (SemaRef.RequireCompleteType(Var->getLocation(),
+                Var->getType(), diag::err_typecheck_incomplete_array_needs_initializer)) {
+          Var->setInvalidDecl();
+          return 0;
+        }
+      }
+    }
+  }
+
----------------
This check belongs in SemaInit.


http://llvm-reviews.chandlerc.com/D1700



More information about the cfe-commits mailing list