diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -3014,8 +3014,15 @@ return false; }; - if (parseMany(parseOp)) - return addErrorSuffix(" in '" + Twine(IDVal) + "' directive"); + while (true) { + if (parseOptionalToken(AsmToken::EndOfStatement)) // return true on success + break; + if (parseOp()) // return false on success + return addErrorSuffix(" in '" + Twine(IDVal) + "' directive"); + if (parseOptionalToken(AsmToken::Comma) && + check(getTok().isNot(AsmToken::String), "expected string")) + return addErrorSuffix(" in '" + Twine(IDVal) + "' directive"); + } return false; } diff --git a/llvm/test/MC/AsmParser/AArch64/directive-parse-err.s b/llvm/test/MC/AsmParser/AArch64/directive-parse-err.s --- a/llvm/test/MC/AsmParser/AArch64/directive-parse-err.s +++ b/llvm/test/MC/AsmParser/AArch64/directive-parse-err.s @@ -13,15 +13,15 @@ .set ident3, 0 $ // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: .set ident3, 0 // EOL COMMENT - // CHECK: [[@LINE+1]]:20: error: unexpected token in '.ascii' directive + // CHECK: [[@LINE+1]]:20: error: expected string in '.ascii' directive .ascii "string1" $ // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: .ascii "string1" // EOL COMMENT - // CHECK: [[@LINE+1]]:20: error: unexpected token in '.asciz' directive + // CHECK: [[@LINE+1]]:20: error: expected string in '.asciz' directive .asciz "string2" $ // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: .asciz "string2" // EOL COMMENT - // CHECK: [[@LINE+1]]:20: error: unexpected token in '.string' directive + // CHECK: [[@LINE+1]]:20: error: expected string in '.string' directive .string "string3" $ // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: .string "string3" // EOL COMMENT diff --git a/llvm/test/MC/Mips/asciiz-directive-bad.s b/llvm/test/MC/Mips/asciiz-directive-bad.s --- a/llvm/test/MC/Mips/asciiz-directive-bad.s +++ b/llvm/test/MC/Mips/asciiz-directive-bad.s @@ -3,6 +3,6 @@ .asciiz 12 # CHECK: :[[@LINE-1]]:11: error: expected string in '.asciiz' directive .asciiz "a"3 -# CHECK: :[[@LINE-1]]:14: error: unexpected token in '.asciiz' directive +# CHECK: :[[@LINE-1]]:14: error: expected string in '.asciiz' directive .asciiz "a", # CHECK: :[[@LINE-1]]:15: error: expected string in '.asciiz' directive