Skip to content

Commit

Permalink
X86AsmParser: Do not process a non-existent token
Browse files Browse the repository at this point in the history
This error can only happen if an unfinished operation is at Eof.

Patch by Brandon Jones

Differential Revision: https://reviews.llvm.org/D57379

llvm-svn: 356972
  • Loading branch information
topperc committed Mar 26, 2019
1 parent 282890d commit 3dce29b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2992,6 +2992,11 @@ bool X86AsmParser::MatchAndEmitATTInstruction(SMLoc IDLoc, unsigned &Opcode,
case Match_MnemonicFail:
break;
}
if (Op.getToken().empty()) {
Error(IDLoc, "instruction must have size higher than 0", EmptyRange,
MatchingInlineAsm);
return true;
}

// FIXME: Ideally, we would only attempt suffix matches for things which are
// valid prefixes, and we could just infer the right unambiguous
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/MC/AsmParser/unfinished-op.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# RUN: not llvm-mc -triple i386-unknown-unknown %s 2>&1 > /dev/null| FileCheck %s --check-prefix=CHECK-ERROR

#CHECK-ERROR: error: instruction must have size higher than 0
.byte 64;""
4 changes: 2 additions & 2 deletions llvm/test/MC/X86/x86_operands.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
addl $a, %eax
# CHECK: addl $3, %eax
addl $1 + 2, %eax

# Disambiguation

# CHECK: addl $1, 8
Expand All @@ -26,7 +26,7 @@
addl $1, (%eax)
# CHECK: addl $1, 8(,%eax)
addl $1, (4+4)(,%eax)

# Indirect Memory Operands
# CHECK: addl $1, 1(%eax)
addl $1, 1(%eax)
Expand Down

0 comments on commit 3dce29b

Please sign in to comment.