Fix a weird inconsistency with hex floats. Previously the lexer

would not eat the "-1" in "0x0p-1", but LiteralSupport would accept
it when extensions are on.  This caused strangeness and failures 
when hexfloats were properly treated as an extension (not error)
in LiteralSupport.

llvm-svn: 59865
This commit is contained in:
Chris Lattner 2008-11-22 07:39:03 +00:00
parent 5424e6d4ec
commit f3cb394f41
2 changed files with 3 additions and 5 deletions

View File

@ -574,8 +574,8 @@ void Lexer::LexNumericConstant(Token &Result, const char *CurPtr) {
return LexNumericConstant(Result, ConsumeChar(CurPtr, Size, Result));
// If we have a hex FP constant, continue.
if (Features.HexFloats &&
(C == '-' || C == '+') && (PrevCh == 'P' || PrevCh == 'p'))
if ((C == '-' || C == '+') && (PrevCh == 'P' || PrevCh == 'p') &&
(Features.HexFloats || !Features.NoExtensions))
return LexNumericConstant(Result, ConsumeChar(CurPtr, Size, Result));
// Update the location of token as well as BufferPtr.

View File

@ -378,10 +378,8 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
}
s = first_non_digit;
if (!PP.getLangOptions().HexFloats) {
if (!PP.getLangOptions().HexFloats)
PP.Diag(TokLoc, diag::ext_hexconstant_invalid);
hadError = true;
}
} else if (saw_period) {
PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
diag::err_hexconstant_requires_exponent);