[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y

Chris Lattner lattner at cs.uiuc.edu
Tue Apr 15 11:10:03 PDT 2003


Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.102 -> 1.103

---
Log message:

Fix bug: Assember2003-04-15-ConstantInitAssertion.llx


---
Diffs of the changes:

Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.102 llvm/lib/AsmParser/llvmAsmParser.y:1.103
--- llvm/lib/AsmParser/llvmAsmParser.y:1.102	Mon Mar  3 17:28:55 2003
+++ llvm/lib/AsmParser/llvmAsmParser.y	Tue Apr 15 11:09:31 2003
@@ -919,8 +919,15 @@
     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;
   }





More information about the llvm-commits mailing list