diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-01-26 22:29:50 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-01-26 22:29:50 +0000 |
commit | 4fefc13b5e804509691cb6e0641b1790352c3293 (patch) | |
tree | 129da7051797fe8e74bbc2fc5ea27d4fd7c523b5 | |
parent | 10096880c8fb08c58d4476577551397bc29f9508 (diff) | |
download | llvm-4fefc13b5e804509691cb6e0641b1790352c3293.tar.gz llvm-4fefc13b5e804509691cb6e0641b1790352c3293.tar.bz2 llvm-4fefc13b5e804509691cb6e0641b1790352c3293.tar.xz |
ARM: improve diagnostics for .word directive
If a complex expression was passed to the .word directive and the first part of
the directive failed to parse, a secondary diagnostic would be produced that
would clutter the error diagnostics. Improve the diagnostics by consuming the
remainder of the statement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200160 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 4 | ||||
-rw-r--r-- | test/MC/ARM/directive-word-diagnostics.s | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 06f2b4ef2e..4577fdee37 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -8093,8 +8093,10 @@ bool ARMAsmParser::parseDirectiveWord(unsigned Size, SMLoc L) { if (getLexer().isNot(AsmToken::EndOfStatement)) { for (;;) { const MCExpr *Value; - if (getParser().parseExpression(Value)) + if (getParser().parseExpression(Value)) { + Parser.eatToEndOfStatement(); return false; + } getParser().getStreamer().EmitValue(Value, Size); diff --git a/test/MC/ARM/directive-word-diagnostics.s b/test/MC/ARM/directive-word-diagnostics.s new file mode 100644 index 0000000000..e68595b778 --- /dev/null +++ b/test/MC/ARM/directive-word-diagnostics.s @@ -0,0 +1,12 @@ +@ RUN: not llvm-mc -triple armv7-eabi -filetype asm -o /dev/null 2>&1 %s \ +@ RUN: | FileCheck %s + + .cpu armv7 + + .type double_diagnostics,%function +double_diagnostics: + .word invalid(invalid) + 32 + +@ CHECK: error: invalid variant 'invalid' +@ CHECK-NOT: error: unexpected token at start of statement + |