[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Chris Lattner
lattner at cs.uiuc.edu
Wed May 21 11:08:01 PDT 2003
Changes in directory llvm/lib/AsmParser:
llvmAsmParser.y updated: 1.111 -> 1.112
---
Log message:
Fix bugs:
Assembler/2003-05-21-EmptyStructTest.ll
Assembler/2003-05-21-MalformedStructCrash.llx
---
Diffs of the changes:
Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.111 llvm/lib/AsmParser/llvmAsmParser.y:1.112
--- llvm/lib/AsmParser/llvmAsmParser.y:1.111 Thu May 15 16:30:00 2003
+++ llvm/lib/AsmParser/llvmAsmParser.y Wed May 21 11:06:56 2003
@@ -945,6 +945,9 @@
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])
@@ -955,6 +958,18 @@
$$ = 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());
More information about the llvm-commits
mailing list