aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/Verifier.cpp9
-rw-r--r--test/Verifier/2008-03-01-AllocaSized.ll8
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index e86c89bfa8..575bb82df7 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -1041,9 +1041,12 @@ void Verifier::visitStoreInst(StoreInst &SI) {
}
void Verifier::visitAllocationInst(AllocationInst &AI) {
- const PointerType *Ptr = AI.getType();
- Assert(Ptr->getAddressSpace() == 0,
- "Allocation instruction pointer not in the generic address space!");
+ const PointerType *PTy = AI.getType();
+ Assert1(PTy->getAddressSpace() == 0,
+ "Allocation instruction pointer not in the generic address space!",
+ &AI);
+ Assert1(PTy->getElementType()->isSized(), "Cannot allocate unsized type",
+ &AI);
visitInstruction(AI);
}
diff --git a/test/Verifier/2008-03-01-AllocaSized.ll b/test/Verifier/2008-03-01-AllocaSized.ll
new file mode 100644
index 0000000000..eb96ced788
--- /dev/null
+++ b/test/Verifier/2008-03-01-AllocaSized.ll
@@ -0,0 +1,8 @@
+; RUN: not llvm-as -f %s -o /dev/null |& grep {Cannot allocate unsized type}
+; PR2113
+
+define void @test() {
+ %A = alloca void()
+ ret void
+}
+