Index: llvm/include/llvm/MC/MCParser/AsmLexer.h =================================================================== --- llvm/include/llvm/MC/MCParser/AsmLexer.h +++ llvm/include/llvm/MC/MCParser/AsmLexer.h @@ -65 +65 @@ - AsmToken LexFloatLiteral(); + AsmToken LexFloatLiteral(bool isDotSeperated); Index: llvm/lib/MC/MCParser/AsmLexer.cpp =================================================================== --- llvm/lib/MC/MCParser/AsmLexer.cpp +++ llvm/lib/MC/MCParser/AsmLexer.cpp @@ -69 +69 @@ -AsmToken AsmLexer::LexFloatLiteral() { +AsmToken AsmLexer::LexFloatLiteral(bool isDotSeperated) { @@ -77 +77,3 @@ - if (*CurPtr == 'e' || *CurPtr == 'E') { + if (isDotSeperated && (*CurPtr == 'e' || *CurPtr == 'E') && + (isDigit(CurPtr[1]) || + ((CurPtr[1] == '-' || CurPtr[1] == '+') && isDigit(CurPtr[2])))) { @@ -79 +81 @@ - if (*CurPtr == '-' || *CurPtr == '+') + if ((*CurPtr == '-' || *CurPtr == '+') && isDigit(CurPtr[1])) @@ -148,3 +150,7 @@ - if (*CurPtr == 'e' || *CurPtr == 'E' || - !IsIdentifierChar(*CurPtr, AllowAtInIdentifier)) - return LexFloatLiteral(); + if ((!IsIdentifierChar(*CurPtr, AllowAtInIdentifier) && + (*CurPtr != 'e' && *CurPtr != 'E')) || + (!IsIdentifierChar(*CurPtr, AllowAtInIdentifier) && + (*CurPtr == 'e' && *CurPtr == 'E') && + (isDigit(CurPtr[1]) || + ((CurPtr[1] == '-' || CurPtr[1] == '+') && isDigit(CurPtr[2]))))) + return LexFloatLiteral(false); @@ -329 +335,4 @@ - if (!isHex && (*CurPtr == '.' || *CurPtr == 'e')) { + if ((!isHex && (*CurPtr == '.' || *CurPtr == 'e')) && + (isDigit(CurPtr[1]) || ((CurPtr[1] == '-' || CurPtr[1] == '+' || + (*CurPtr == '.' && CurPtr[1] == 'e')) && + isDigit(CurPtr[2])))) { @@ -331 +340,3 @@ - return LexFloatLiteral(); + if (CurPtr[-1] == '.') + return LexFloatLiteral(true); + return LexFloatLiteral(false); Index: llvm/test/MC/AsmParser/floating-literals.s =================================================================== --- llvm/test/MC/AsmParser/floating-literals.s +++ llvm/test/MC/AsmParser/floating-literals.s @@ -53,2 +53,5 @@ -//.double -1.2e+ -//.double -1.2e + +#CHECK-ERROR: unexpected token in '.double' directive +.double -1.2e+ +#CHECK-ERROR: unexpected token in '.double' directive +.double -1.2e