]> granicus.if.org Git - clang/commitdiff
Fix a weird inconsistency with hex floats. Previously the lexer
authorChris Lattner <sabre@nondot.org>
Sat, 22 Nov 2008 07:39:03 +0000 (07:39 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 22 Nov 2008 07:39:03 +0000 (07:39 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59865 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Lexer.cpp
lib/Lex/LiteralSupport.cpp

index b4d0717cd7881de91ac3fca452f283d8dfe13f25..1e9789b14a7a1338fc45aa4ccef5887860788e08 100644 (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.
index 6a1fad52bfe51891a4007b190e6a1e7ed2777ecb..fbd2c326ea77995e2b514fde31fed6c419fba203 100644 (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);