summaryrefslogtreecommitdiff
path: root/lib/MC/MCParser
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2013-12-28 06:39:29 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2013-12-28 06:39:29 +0000
commit14b42a1c92b47bced8e6b94a0213a8970d1c0edd (patch)
treee7ac97681b39c1a7c90b6488a3bfaadba29a8bf1 /lib/MC/MCParser
parentb5191e98e883fe804c400cc5187fe54d41a808e0 (diff)
downloadllvm-14b42a1c92b47bced8e6b94a0213a8970d1c0edd.tar.gz
llvm-14b42a1c92b47bced8e6b94a0213a8970d1c0edd.tar.bz2
llvm-14b42a1c92b47bced8e6b94a0213a8970d1c0edd.tar.xz
AsmParser: cleanup diagnostics for .rep/.rept
Avoid double diagnostics for invalid expressions for count. Improve caret location for negative count. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198099 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCParser')
-rw-r--r--lib/MC/MCParser/AsmParser.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index b4c5f50a99..4b83144f3b 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -3958,12 +3958,19 @@ void AsmParser::instantiateMacroLikeBody(MCAsmMacro *M, SMLoc DirectiveLoc,
/// parseDirectiveRept
/// ::= .rep | .rept count
bool AsmParser::parseDirectiveRept(SMLoc DirectiveLoc, StringRef Dir) {
+ const MCExpr *CountExpr;
+ SMLoc CountLoc = getTok().getLoc();
+ if (parseExpression(CountExpr))
+ return true;
+
int64_t Count;
- if (parseAbsoluteExpression(Count))
- return TokError("unexpected token in '" + Dir + "' directive");
+ if (!CountExpr->EvaluateAsAbsolute(Count)) {
+ eatToEndOfStatement();
+ return Error(CountLoc, "unexpected token in '" + Dir + "' directive");
+ }
if (Count < 0)
- return TokError("Count is negative");
+ return Error(CountLoc, "Count is negative");
if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '" + Dir + "' directive");