diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 7818586dfa4..47125ca954c 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1633,6 +1633,7 @@ bool LLParser::ParseIndexList(SmallVectorImpl &Indices, while (EatIfPresent(lltok::comma)) { if (Lex.getKind() == lltok::MetadataVar) { + if (Indices.empty()) return TokError("expected index"); AteExtraComma = true; return false; } diff --git a/test/Assembler/extractvalue-no-idx.ll b/test/Assembler/extractvalue-no-idx.ll new file mode 100644 index 00000000000..b3132097eb1 --- /dev/null +++ b/test/Assembler/extractvalue-no-idx.ll @@ -0,0 +1,8 @@ +; RUN: not llvm-as < %s 2>&1 | FileCheck %s + +; CHECK: expected index + +define void @f1() { + extractvalue <{ i32, i32 }> undef, !dbg !0 + ret void +}