aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AsmParser/llvmAsmParser.y
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-05-21 16:06:56 +0000
committerChris Lattner <sabre@nondot.org>2003-05-21 16:06:56 +0000
commitc6212f19208337162d9377e77e8c516129966b84 (patch)
tree2016fb97ec773bfa8277d9d9ec07b7860b0b3d2a /lib/AsmParser/llvmAsmParser.y
parentd32cac600946ea1aeb959931bd73d37a66a42939 (diff)
downloadexternal_llvm-c6212f19208337162d9377e77e8c516129966b84.zip
external_llvm-c6212f19208337162d9377e77e8c516129966b84.tar.gz
external_llvm-c6212f19208337162d9377e77e8c516129966b84.tar.bz2
Fix bugs:
Assembler/2003-05-21-EmptyStructTest.ll Assembler/2003-05-21-MalformedStructCrash.llx git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6255 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/llvmAsmParser.y')
-rw-r--r--lib/AsmParser/llvmAsmParser.y15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 75df31c..7945b37 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -945,6 +945,9 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
ThrowException("Cannot make struct constant with type: '" +
(*$1)->getDescription() + "'!");
+ if ($3->size() != STy->getNumContainedTypes())
+ ThrowException("Illegal number of initializers for structure type!");
+
// 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])
@@ -956,6 +959,18 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
$$ = ConstantStruct::get(STy, *$3);
delete $1; delete $3;
}
+ | Types '{' '}' {
+ const StructType *STy = dyn_cast<const StructType>($1->get());
+ if (STy == 0)
+ ThrowException("Cannot make struct constant with type: '" +
+ (*$1)->getDescription() + "'!");
+
+ if (STy->getNumContainedTypes() != 0)
+ ThrowException("Illegal number of initializers for structure type!");
+
+ $$ = ConstantStruct::get(STy, std::vector<Constant*>());
+ delete $1;
+ }
| Types NULL_TOK {
const PointerType *PTy = dyn_cast<const PointerType>($1->get());
if (PTy == 0)