[llvm] r200160 - ARM: improve diagnostics for .word directive
Saleem Abdulrasool
compnerd at compnerd.org
Sun Jan 26 14:29:50 PST 2014
Author: compnerd
Date: Sun Jan 26 16:29:50 2014
New Revision: 200160
URL: http://llvm.org/viewvc/llvm-project?rev=200160&view=rev
Log:
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.
Added:
llvm/trunk/test/MC/ARM/directive-word-diagnostics.s
Modified:
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=200160&r1=200159&r2=200160&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Sun Jan 26 16:29:50 2014
@@ -8093,8 +8093,10 @@ bool ARMAsmParser::parseDirectiveWord(un
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);
Added: llvm/trunk/test/MC/ARM/directive-word-diagnostics.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/directive-word-diagnostics.s?rev=200160&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/directive-word-diagnostics.s (added)
+++ llvm/trunk/test/MC/ARM/directive-word-diagnostics.s Sun Jan 26 16:29:50 2014
@@ -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
+
More information about the llvm-commits
mailing list