Index: lib/MC/MCParser/ELFAsmParser.cpp =================================================================== --- lib/MC/MCParser/ELFAsmParser.cpp +++ lib/MC/MCParser/ELFAsmParser.cpp @@ -174,27 +174,18 @@ .Case(".protected", MCSA_Protected) .Default(MCSA_Invalid); assert(Attr != MCSA_Invalid && "unexpected symbol attribute directive!"); - if (getLexer().isNot(AsmToken::EndOfStatement)) { - while (true) { - StringRef Name; - - if (getParser().parseIdentifier(Name)) - return TokError("expected identifier in directive"); - - MCSymbol *Sym = getContext().getOrCreateSymbol(Name); - - getStreamer().EmitSymbolAttribute(Sym, Attr); - - if (getLexer().is(AsmToken::EndOfStatement)) - break; + auto parseOp = [&]() -> bool { + StringRef Name; + if (getParser().parseIdentifier(Name)) + return true; + MCSymbol *Sym = getContext().getOrCreateSymbol(Name); + getStreamer().EmitSymbolAttribute(Sym, Attr); + return false; + }; - if (getLexer().isNot(AsmToken::Comma)) - return TokError("unexpected token in directive"); - Lex(); - } - } + if (parseMany(parseOp)) + return addErrorSuffix(" in '" + Twine(Directive) + "' directive"); - Lex(); return false; } Index: test/MC/AsmParser/AArch64/directive-parse-err.s =================================================================== --- test/MC/AsmParser/AArch64/directive-parse-err.s +++ test/MC/AsmParser/AArch64/directive-parse-err.s @@ -1,5 +1,5 @@ // RUN: not llvm-mc -triple aarch64-unknown-unknown %s 2>&1 | FileCheck %s -// RUN: not llvm-mc -triple aarch64-unknown-unknown %s 2>&1 | grep "error:" | count 60 +// RUN: not llvm-mc -triple aarch64-unknown-unknown %s 2>&1 | grep "error:" | count 61 // CHECK: [[@LINE+1]]:19: error: unexpected token in '.equ' directive .equ ident1, 0 $ @@ -205,6 +205,10 @@ .global a2 $ // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: .global a2 # EOL COMMENT + // CHECK: [[@LINE+1]]:31: error: unexpected token + .hidden a1 $ + // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: + .hidden a1 # EOL COMMENT // CHECK: [[@LINE+1]]:31: error: unexpected token in directive .lazy_reference a3 $ // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: