From 7e9e31ebaf9d63d921e4e3f3c48a1536c145eebb Mon Sep 17 00:00:00 2001 From: Artyom Skrobov Date: Thu, 29 May 2014 11:26:15 +0000 Subject: [PATCH] Add missing check when MatchInstructionImpl() reports failure llvm-svn: 209802 --- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 2 ++ llvm/test/MC/AArch64/basic-a64-diagnostics.s | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 65b77c5..3337118 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -3794,6 +3794,8 @@ bool AArch64AsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, case Match_InvalidLabel: case Match_MSR: case Match_MRS: { + if (ErrorInfo >= Operands.size()) + return Error(IDLoc, "too few operands for instruction"); // Any time we get here, there's nothing fancy to do. Just get the // operand SMLoc and display the diagnostic. SMLoc ErrorLoc = ((AArch64Operand *)Operands[ErrorInfo])->getStartLoc(); diff --git a/llvm/test/MC/AArch64/basic-a64-diagnostics.s b/llvm/test/MC/AArch64/basic-a64-diagnostics.s index a4a3b13..118df36 100644 --- a/llvm/test/MC/AArch64/basic-a64-diagnostics.s +++ b/llvm/test/MC/AArch64/basic-a64-diagnostics.s @@ -395,6 +395,7 @@ cmn w11, w12, lsr #-1 cmn w11, w12, lsr #32 cmn w19, wzr, asr #-1 + cmn wsp, w0 cmn wzr, wzr, asr #32 cmn x9, x10, lsl #-1 cmn x9, x10, lsl #64 @@ -417,6 +418,9 @@ // CHECK-ERROR-NEXT: error: expected integer shift amount // CHECK-ERROR-NEXT: cmn w19, wzr, asr #-1 // CHECK-ERROR-NEXT: ^ +// CHECK-ERROR-NEXT: error: too few operands for instruction +// CHECK-ERROR-NEXT: cmn wsp, w0 +// CHECK-ERROR-NEXT: ^ // CHECK-ERROR-NEXT: error: expected 'lsl', 'lsr' or 'asr' with optional integer in range [0, 31] // CHECK-ERROR-NEXT: cmn wzr, wzr, asr #32 // CHECK-ERROR-NEXT: ^ -- 2.7.4