[cfe-commits] r141798 - in /cfe/trunk: lib/Lex/Lexer.cpp lib/Lex/LiteralSupport.cpp test/Lexer/hexfloat.cpp

Douglas Gregor dgregor at apple.com
Wed Oct 12 11:51:03 PDT 2011


Author: dgregor
Date: Wed Oct 12 13:51:02 2011
New Revision: 141798

URL: http://llvm.org/viewvc/llvm-project?rev=141798&view=rev
Log:
We do parse hexfloats in C++11; make it actually work.

Modified:
    cfe/trunk/lib/Lex/Lexer.cpp
    cfe/trunk/lib/Lex/LiteralSupport.cpp
    cfe/trunk/test/Lexer/hexfloat.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=141798&r1=141797&r2=141798&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Oct 12 13:51:02 2011
@@ -1358,8 +1358,7 @@
   }
 
   // If we have a hex FP constant, continue.
-  if ((C == '-' || C == '+') && (PrevCh == 'P' || PrevCh == 'p') &&
-      !Features.CPlusPlus0x)
+  if ((C == '-' || C == '+') && (PrevCh == 'P' || PrevCh == 'p'))
     return LexNumericConstant(Result, ConsumeChar(CurPtr, Size, Result));
 
   // Update the location of token as well as BufferPtr.

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=141798&r1=141797&r2=141798&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Wed Oct 12 13:51:02 2011
@@ -562,9 +562,6 @@
       }
       s = first_non_digit;
 
-      // In C++0x, we cannot support hexadecmial floating literals because
-      // they conflict with user-defined literals, so we warn in previous
-      // versions of C++ by default.
       if (!PP.getLangOptions().HexFloats)
         PP.Diag(TokLoc, diag::ext_hexconstant_invalid);
     } else if (saw_period) {

Modified: cfe/trunk/test/Lexer/hexfloat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/hexfloat.cpp?rev=141798&r1=141797&r2=141798&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/hexfloat.cpp (original)
+++ cfe/trunk/test/Lexer/hexfloat.cpp Wed Oct 12 13:51:02 2011
@@ -1,9 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
-// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
-// XFAIL: *
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s
+float f = 0x1p+1; // expected-warning{{hexadecimal floating constants are a C99 feature}}
 
-#ifndef __GXX_EXPERIMENTAL_CXX0X__
-float f = 0x1p+1; // expected-warning {{incompatible with C++0x}}
-#else
-float f = 0x1p+1; // expected-warning {{invalid suffix}}
-#endif





More information about the cfe-commits mailing list