diff --git a/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h b/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h index c37889cfc5096..fc10e33bcf6b9 100644 --- a/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h +++ b/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h @@ -89,6 +89,7 @@ class MCAsmParserExtension { const Twine &Msg = "unexpected token") { return getParser().parseToken(T, Msg); } + bool parseEOL() { return getParser().parseEOL(); } bool parseMany(function_ref parseOne, bool hasComma = true) { return getParser().parseMany(parseOne, hasComma); diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 396bae6afebdc..a7ec6214bb80a 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -5594,9 +5594,7 @@ bool AArch64AsmParser::parseDirectiveInst(SMLoc Loc) { return false; }; - if (parseMany(parseOp)) - return addErrorSuffix(" in '.inst' directive"); - return false; + return parseMany(parseOp); } // parseDirectiveTLSDescCall: @@ -5752,9 +5750,7 @@ bool AArch64AsmParser::parseDirectiveUnreq(SMLoc L) { return TokError("unexpected input in .unreq directive."); RegisterReqs.erase(Parser.getTok().getIdentifier().lower()); Parser.Lex(); // Eat the identifier. - if (parseToken(AsmToken::EndOfStatement)) - return addErrorSuffix("in '.unreq' directive"); - return false; + return parseToken(AsmToken::EndOfStatement); } bool AArch64AsmParser::parseDirectiveCFINegateRAState() { @@ -5787,16 +5783,13 @@ bool AArch64AsmParser::parseDirectiveVariantPCS(SMLoc L) { MCSymbol *Sym = getContext().lookupSymbol(SymbolName); if (!Sym) - return TokError("unknown symbol in '.variant_pcs' directive"); + return TokError("unknown symbol"); Parser.Lex(); // Eat the symbol - // Shouldn't be any more tokens - if (parseToken(AsmToken::EndOfStatement)) - return addErrorSuffix(" in '.variant_pcs' directive"); - + if (parseEOL()) + return true; getTargetStreamer().emitDirectiveVariantPCS(Sym); - return false; } diff --git a/llvm/test/MC/AArch64/directive-variant_pcs-err.s b/llvm/test/MC/AArch64/directive-variant_pcs-err.s index 98cf703b564e3..70bb5451d3716 100644 --- a/llvm/test/MC/AArch64/directive-variant_pcs-err.s +++ b/llvm/test/MC/AArch64/directive-variant_pcs-err.s @@ -1,17 +1,11 @@ // RUN: not llvm-mc -triple aarch64-unknown-none-eabi -filetype asm -o - %s 2>&1 | FileCheck %s +// CHECK: [[#@LINE+1]]:13: error: expected symbol name .variant_pcs -// CHECK: error: expected symbol name -// CHECK-NEXT: .variant_pcs -// CHECK-NEXT: ^ +// CHECK: [[#@LINE+1]]:14: error: unknown symbol .variant_pcs foo -// CHECK: error: unknown symbol in '.variant_pcs' directive -// CHECK-NEXT: .variant_pcs foo -// CHECK-NEXT: ^ .global foo +// CHECK: [[#@LINE+1]]:18: error: expected newline .variant_pcs foo bar -// CHECK: error: unexpected token in '.variant_pcs' directive -// CHECK-NEXT: .variant_pcs foo bar -// CHECK-NEXT: ^