Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -748,11 +748,11 @@ /// \brief Throw away the rest of the line for testing purposes. void AsmParser::eatToEndOfStatement() { while (Lexer.isNot(AsmToken::EndOfStatement) && Lexer.isNot(AsmToken::Eof)) - Lex(); + Lexer.Lex(); // Eat EOL. if (Lexer.is(AsmToken::EndOfStatement)) - Lex(); + Lexer.Lex(); } StringRef AsmParser::parseStringToEndOfStatement() { @@ -2408,7 +2408,7 @@ SMLoc PrefixLoc = getLexer().getLoc(); // Consume the prefix character, and check for a following identifier. - Lex(); + Lexer.Lex(); if (Lexer.isNot(AsmToken::Identifier)) return true; @@ -2419,7 +2419,7 @@ // Construct the joined identifier and consume the token. Res = StringRef(PrefixLoc.getPointer(), getTok().getIdentifier().size() + 1); - Lex(); + Lexer.Lex(); return false; } @@ -2428,7 +2428,7 @@ Res = getTok().getIdentifier(); - Lex(); // Consume the identifier token. + Lexer.Lex(); // Consume the identifier token. return false; } @@ -2686,14 +2686,15 @@ // have to manually parse unary prefixes. bool IsNeg = false; if (getLexer().is(AsmToken::Minus)) { - Lex(); + Lexer.Lex(); IsNeg = true; } else if (getLexer().is(AsmToken::Plus)) - Lex(); + Lexer.Lex(); - if (getLexer().isNot(AsmToken::Integer) && - getLexer().isNot(AsmToken::Real) && - getLexer().isNot(AsmToken::Identifier)) + if (Lexer.is(AsmToken::Error)) + return TokError(Lexer.getErr()); + if (Lexer.isNot(AsmToken::Integer) && Lexer.isNot(AsmToken::Real) && + Lexer.isNot(AsmToken::Identifier)) return TokError("unexpected token in directive"); // Convert to an APFloat. @@ -2720,10 +2721,10 @@ getStreamer().EmitIntValue(AsInt.getLimitedValue(), AsInt.getBitWidth() / 8); - if (getLexer().is(AsmToken::EndOfStatement)) + if (Lexer.is(AsmToken::EndOfStatement)) break; - if (getLexer().isNot(AsmToken::Comma)) + if (Lexer.isNot(AsmToken::Comma)) return TokError("unexpected token in directive"); Lex(); } @@ -3779,11 +3780,16 @@ // Eat the end of statement. Lex(); + // Consuming deferred text, so use Lexer.Lex to ignore Lexing Errors AsmToken EndToken, StartToken = getTok(); unsigned MacroDepth = 0; - // Lex the macro definition. for (;;) { + // Ignore Lexing errors in macros. + while (Lexer.is(AsmToken::Error)) { + Lexer.Lex(); + } + // Check whether we have reached the end of the file. if (getLexer().is(AsmToken::Eof)) return Error(DirectiveLoc, "no matching '.endmacro' in definition"); @@ -3794,7 +3800,7 @@ getTok().getIdentifier() == ".endmacro") { if (MacroDepth == 0) { // Outermost macro. EndToken = getTok(); - Lex(); + Lexer.Lex(); if (getLexer().isNot(AsmToken::EndOfStatement)) return TokError("unexpected token in '" + EndToken.getIdentifier() + "' directive"); Index: test/MC/AsmParser/floating-literals.s =================================================================== --- test/MC/AsmParser/floating-literals.s +++ test/MC/AsmParser/floating-literals.s @@ -58,25 +58,19 @@ .float -0x1.0p0 # CHECK-ERROR: invalid hexadecimal floating-point constant: expected at least one exponent digit -# CHECK-ERROR: unexpected token in directive .float 0xa.apa # CHECK-ERROR: invalid hexadecimal floating-point constant: expected at least one exponent digit -# CHECK-ERROR: unexpected token in directive .double -0x1.2p+ # CHECK-ERROR: invalid hexadecimal floating-point constant: expected at least one exponent digit -# CHECK-ERROR: unexpected token in directive .double -0x1.2p # CHECK-ERROR: invalid hexadecimal floating-point constant: expected at least one significand digit -# CHECK-ERROR: unexpected token in directive .float 0xp2 # CHECK-ERROR: invalid hexadecimal floating-point constant: expected at least one significand digit -# CHECK-ERROR: unexpected token in directive .float 0x.p5 # CHECK-ERROR: error: invalid hexadecimal floating-point constant: expected exponent part 'p' -# CHECK-ERROR: unexpected token in directive .float 0x1.2 Index: test/MC/AsmParser/macro_parsing.s =================================================================== --- /dev/null +++ test/MC/AsmParser/macro_parsing.s @@ -0,0 +1,10 @@ +# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s + + .macro DEF num + int $0x\num + .endm + DEF 02 + DEF 10 + +# CHECK: int $2 +# CHECK: int $16