]> granicus.if.org Git - llvm/commitdiff
X86AsmParser: Do not process a non-existent token
authorCraig Topper <craig.topper@intel.com>
Tue, 26 Mar 2019 03:12:41 +0000 (03:12 +0000)
committerCraig Topper <craig.topper@intel.com>
Tue, 26 Mar 2019 03:12:41 +0000 (03:12 +0000)
This error can only happen if an unfinished operation is at Eof.

Patch by Brandon Jones

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356972 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmParser/X86AsmParser.cpp
test/MC/AsmParser/unfinished-op.s [new file with mode: 0644]
test/MC/X86/x86_operands.s

index 75db48928c9c093bde4fac176189338c5f672830..273edadb06151d3ee6591bc53cfad56392abf387 100644 (file)
@@ -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
diff --git a/test/MC/AsmParser/unfinished-op.s b/test/MC/AsmParser/unfinished-op.s
new file mode 100644 (file)
index 0000000..079e036
--- /dev/null
@@ -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;""
index 3aa1b8d7fb8fd43ceefa2e9ae6ef7298e1cf259c..70b11faf003e300e938d1b9e8de9c148ccd33bcc 100644 (file)
@@ -9,7 +9,7 @@
         addl $a, %eax
 # CHECK: addl $3, %eax
         addl $1 + 2, %eax
-        
+
 # Disambiguation
 
 # CHECK: addl $1, 8
@@ -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)