summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp7
-rw-r--r--llvm/test/Assembler/insertvalue-invalid-type.ll9
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 25b2a315023..adf4c9073ab 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -4951,8 +4951,13 @@ int LLParser::ParseInsertValue(Instruction *&Inst, PerFunctionState &PFS) {
if (!Val0->getType()->isAggregateType())
return Error(Loc0, "insertvalue operand must be aggregate type");
- if (!ExtractValueInst::getIndexedType(Val0->getType(), Indices))
+ Type *IndexedType = ExtractValueInst::getIndexedType(Val0->getType(), Indices);
+ if (!IndexedType)
return Error(Loc0, "invalid indices for insertvalue");
+ if (IndexedType != Val1->getType())
+ return Error(Loc1, "insertvalue operand and field disagree in type: '" +
+ getTypeString(Val1->getType()) + "' instead of '" +
+ getTypeString(IndexedType) + "'");
Inst = InsertValueInst::Create(Val0, Val1, Indices);
return AteExtraComma ? InstExtraComma : InstNormal;
}
diff --git a/llvm/test/Assembler/insertvalue-invalid-type.ll b/llvm/test/Assembler/insertvalue-invalid-type.ll
new file mode 100644
index 00000000000..6be20e56a4f
--- /dev/null
+++ b/llvm/test/Assembler/insertvalue-invalid-type.ll
@@ -0,0 +1,9 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+; CHECK: insertvalue operand and field disagree in type: 'i8*' instead of 'i32'
+
+define void @test() {
+entry:
+ insertvalue { i32, i32 } undef, i8* null, 0
+ ret void
+}
OpenPOWER on IntegriCloud