]> granicus.if.org Git - llvm/commitdiff
Fix bug: Assember2003-04-15-ConstantInitAssertion.llx
authorChris Lattner <sabre@nondot.org>
Tue, 15 Apr 2003 16:09:31 +0000 (16:09 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 15 Apr 2003 16:09:31 +0000 (16:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5777 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/llvmAsmParser.y

index f2135a7ad25383cf41aa7a15c5e6c327e8b784d7..fdc4213436e041cc7551c9e5a6352f1fea565e9f 100644 (file)
@@ -919,8 +919,15 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
     if (STy == 0)
       ThrowException("Cannot make struct constant with type: '" + 
                      (*$1)->getDescription() + "'!");
-    // FIXME: TODO: Check to see that the constants are compatible with the type
-    // initializer!
+
+    // Check to ensure that constants are compatible with the type initializer!
+    for (unsigned i = 0, e = $3->size(); i != e; ++i)
+      if ((*$3)[i]->getType() != STy->getElementTypes()[i])
+        ThrowException("Expected type '" +
+                       STy->getElementTypes()[i]->getDescription() +
+                       "' for element #" + utostr(i) +
+                       " of structure initializer!");
+
     $$ = ConstantStruct::get(STy, *$3);
     delete $1; delete $3;
   }