mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
AsmParser: Don't crash when insertvalue has bad operands
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228813 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
4762c0b5d1
commit
94d09cbb9f
2 files changed
+15
-1
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user