[cfe-commits] r44431 - in /cfe/trunk: Lex/LiteralSupport.cpp test/Lexer/11-27-2007-FloatLiterals.c
Christopher Lamb
christopher.lamb at gmail.com
Wed Nov 28 22:06:27 PST 2007
Author: clamb
Date: Thu Nov 29 00:06:27 2007
New Revision: 44431
URL: http://llvm.org/viewvc/llvm-project?rev=44431&view=rev
Log:
Support floating point literals of the form "1e-16f" which specify an exponent but no decimal point.
Added:
cfe/trunk/test/Lexer/11-27-2007-FloatLiterals.c
Modified:
cfe/trunk/Lex/LiteralSupport.cpp
Modified: cfe/trunk/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/LiteralSupport.cpp?rev=44431&r1=44430&r2=44431&view=diff
==============================================================================
--- cfe/trunk/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/Lex/LiteralSupport.cpp Thu Nov 29 00:06:27 2007
@@ -261,7 +261,7 @@
s = SkipOctalDigits(s);
if (s == ThisTokEnd) {
// Done.
- } else if (isxdigit(*s)) {
+ } else if (isxdigit(*s) && !(*s == 'e' || *s == 'E')) {
TokLoc = PP.AdvanceToTokenCharacter(TokLoc, s-begin);
Diag(TokLoc, diag::err_invalid_octal_digit, std::string(s, s+1));
return;
@@ -290,7 +290,7 @@
s = SkipDigits(s);
if (s == ThisTokEnd) {
// Done.
- } else if (isxdigit(*s)) {
+ } else if (isxdigit(*s) && !(*s == 'e' || *s == 'E')) {
Diag(TokLoc, diag::err_invalid_decimal_digit, std::string(s, s+1));
return;
} else if (*s == '.') {
Added: cfe/trunk/test/Lexer/11-27-2007-FloatLiterals.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/11-27-2007-FloatLiterals.c?rev=44431&view=auto
==============================================================================
--- cfe/trunk/test/Lexer/11-27-2007-FloatLiterals.c (added)
+++ cfe/trunk/test/Lexer/11-27-2007-FloatLiterals.c Thu Nov 29 00:06:27 2007
@@ -0,0 +1,7 @@
+// RUN: clang %s -emit-llvm 2>&1 | grep 0x3BFD83C940000000 | count 2
+// RUN: clang %s -emit-llvm 2>&1 | grep 0x46A3B8B5B5056E16 | count 2
+
+float F = 1e-19f;
+double D = 2e32;
+float F2 = 01e-19f;
+double D2 = 02e32;
More information about the cfe-commits
mailing list