1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

AsmParser: Check ConstantExpr insertvalue operands for type correctness

llvm-svn: 230206
This commit is contained in:
David Majnemer 2015-02-23 07:13:52 +00:00
parent 45c9c54cc7
commit c9335a127a
2 changed files with 15 additions and 1 deletions

View File

@ -2609,8 +2609,15 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
return true; return true;
if (!Val0->getType()->isAggregateType()) if (!Val0->getType()->isAggregateType())
return Error(ID.Loc, "insertvalue operand must be aggregate type"); return Error(ID.Loc, "insertvalue operand must be aggregate type");
if (!ExtractValueInst::getIndexedType(Val0->getType(), Indices)) Type *IndexedType =
ExtractValueInst::getIndexedType(Val0->getType(), Indices);
if (!IndexedType)
return Error(ID.Loc, "invalid indices for insertvalue"); return Error(ID.Loc, "invalid indices for insertvalue");
if (IndexedType != Val1->getType())
return Error(ID.Loc, "insertvalue operand and field disagree in type: '" +
getTypeString(Val1->getType()) +
"' instead of '" + getTypeString(IndexedType) +
"'");
ID.ConstantVal = ConstantExpr::getInsertValue(Val0, Val1, Indices); ID.ConstantVal = ConstantExpr::getInsertValue(Val0, Val1, Indices);
ID.Kind = ValID::t_Constant; ID.Kind = ValID::t_Constant;
return false; return false;

View File

@ -0,0 +1,7 @@
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
; CHECK: insertvalue operand and field disagree in type: 'i32' instead of 'i64'
define <{ i32 }> @test() {
ret <{ i32 }> insertvalue (<{ i64 }> zeroinitializer, i32 4, 0)
}