]> granicus.if.org Git - clang/commitdiff
add a hack so that codegen doesn't abort on missing sema of initializers, now
authorChris Lattner <sabre@nondot.org>
Mon, 17 Dec 2007 05:17:42 +0000 (05:17 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 17 Dec 2007 05:17:42 +0000 (05:17 +0000)
we emit stuff like this:

abort on missing sema of initializers, now
we emit stuff like this:

t3.c:1:24: warning: cannot codegen this initializer yet
const char x[2][4] = { { 'a', 'b', '\0', '\0' }, { 'c', 'd', 'e', '\0' } };
                       ^~~~~~~~~~~~~~~~~~~~~~~~

This should be removed when sema is finished.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45086 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CodeGenModule.cpp

index ea908d398c9285d74ed917fc4f31c7c13b589a85..76bf40353ae1f4a5c1f4e880b402f4e40a38c07d 100644 (file)
@@ -281,7 +281,15 @@ static llvm::Constant *GenerateConstantCast(const Expr *Expression,
 /// struct typed variables.
 static llvm::Constant *GenerateAggregateInit(const InitListExpr *ILE, 
                                              CodeGenModule &CGM) {
-  assert (ILE->getType()->isArrayType() || ILE->getType()->isStructureType());
+  if (ILE->getType()->isVoidType()) {
+    // FIXME: Remove this when sema of initializers is finished (and the code
+    // below).
+    CGM.WarnUnsupported(ILE, "initializer");
+    return 0;
+  }
+  
+  assert((ILE->getType()->isArrayType() || ILE->getType()->isStructureType()) &&
+         "Bad type for init list!");
   CodeGenTypes& Types = CGM.getTypes();
 
   unsigned NumInitElements = ILE->getNumInits();
@@ -309,6 +317,12 @@ static llvm::Constant *GenerateAggregateInit(const InitListExpr *ILE,
   unsigned i = 0;
   for (i = 0; i < NumInitableElts; ++i) {
     llvm::Constant *C = GenerateConstantExpr(ILE->getInit(i), CGM);
+    // FIXME: Remove this when sema of initializers is finished (and the code
+    // above).
+    if (C == 0 && ILE->getInit(i)->getType()->isVoidType()) {
+      if (ILE->getType()->isVoidType()) return 0;
+      return llvm::UndefValue::get(CType);
+    }
     assert (C && "Failed to create initialiser expression");
     Elts.push_back(C);
   }