aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-04-15 16:09:31 +0000
committerChris Lattner <sabre@nondot.org>2003-04-15 16:09:31 +0000
commitaf76d0ea0bc15e87a32aad9c86808eba34026f20 (patch)
treeb0744af1ef1bf56bc1b3d7ff17692e39f4e8a69d
parent9fa01f2fa5a7c7dea56b7e25577dd9ac90401a7a (diff)
Fix bug: Assember2003-04-15-ConstantInitAssertion.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5777 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AsmParser/llvmAsmParser.y11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index f2135a7ad2..fdc4213436 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -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;
}