Index: llvm/lib/MC/MCParser/AsmParser.cpp =================================================================== --- llvm/lib/MC/MCParser/AsmParser.cpp +++ llvm/lib/MC/MCParser/AsmParser.cpp @@ -4676,15 +4676,20 @@ /// ::= .ds.{b, d, l, p, s, w, x} expression bool AsmParser::parseDirectiveDS(StringRef IDVal, unsigned Size) { SMLoc NumValuesLoc = Lexer.getLoc(); - int64_t NumValues; - if (checkForValidSection() || parseAbsoluteExpression(NumValues)) - return true; - - if (NumValues < 0) { + if (Lexer.getKind() == AsmToken::Plus) + Lexer.Lex(); + else if (Lexer.getKind() == AsmToken::Minus) { Warning(NumValuesLoc, "'" + Twine(IDVal) + "' directive with negative repeat count has no effect"); return false; } + if (Lexer.getKind() != AsmToken::Integer) + return Error(NumValuesLoc, "directive only accepts integer values"); + + int64_t NumValues; + if (checkForValidSection() || parseAbsoluteExpression(NumValues)) + return true; + if (parseToken(AsmToken::EndOfStatement, "unexpected token in '" + Twine(IDVal) + "' directive")) return true; Index: llvm/test/MC/AsmParser/directive_ds.s =================================================================== --- llvm/test/MC/AsmParser/directive_ds.s +++ llvm/test/MC/AsmParser/directive_ds.s @@ -56,3 +56,7 @@ # CHECK-ERROR: error: unexpected token in '.ds' directive TEST9: .ds 1 2 + +# CHECK-ERROR: error: directive only accepts integer values +TEST10: + .ds 5.0