ARM IAS: fix diagnostics of improper qualification
authorSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 12 Jan 2014 05:25:44 +0000 (05:25 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 12 Jan 2014 05:25:44 +0000 (05:25 +0000)
An improper qualifier would result in a superfluous error due to the parser not
consuming the remainder of the statement.  Simply consume the remainder of the
statement to avoid the error.

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

lib/Target/ARM/AsmParser/ARMAsmParser.cpp
test/MC/ARM/arm-qualifier-diagnostics.s [new file with mode: 0644]

index b1ac198c6c222c1578ae02ab4584d1d9921e3d7e..b8890a37df9d77f8881353d82234966d25ca2990 100644 (file)
@@ -5325,6 +5325,7 @@ bool ARMAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
     // For for ARM mode generate an error if the .n qualifier is used.
     if (ExtraToken == ".n" && !isThumb()) {
       SMLoc Loc = SMLoc::getFromPointer(NameLoc.getPointer() + Start);
+      Parser.eatToEndOfStatement();
       return Error(Loc, "instruction with .n (narrow) qualifier not allowed in "
                    "arm mode");
     }
diff --git a/test/MC/ARM/arm-qualifier-diagnostics.s b/test/MC/ARM/arm-qualifier-diagnostics.s
new file mode 100644 (file)
index 0000000..8b75eee
--- /dev/null
@@ -0,0 +1,15 @@
+@ RUN: not llvm-mc -triple armv7-eabi -filetype asm -o - %s 2>&1 | FileCheck %s
+
+       .syntax unified
+
+       .type function,%function
+function:
+       ldr.n r0, [r0]
+
+@ CHECK: error: instruction with .n (narrow) qualifier not allowed in arm mode
+@ CHECK:       ldr.n r0, [r0]
+@ CHECK:           ^
+@ CHECK-NOT: error: unexpected token in operand
+@ CHECK-NOT:   ldr.n r0, [r0]
+@ CHECK-NOT:            ^
+