[cfe-dev] Support floating point literals with exponent but no point
Christopher Lamb
christopher.lamb at gmail.com
Sun Nov 25 18:58:38 PST 2007
GCC allows literals of the form "1e-16f" which clang currently
rejects. The following patch is proposed:
Index: Lex/LiteralSupport.cpp
===================================================================
--- Lex/LiteralSupport.cpp (revision 44312)
+++ Lex/LiteralSupport.cpp (working copy)
@@ -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 == '.') {
With testcase:
float F = 1e-19f;
double D = 2e32;
float F2 = 01e-19f;
double D2 = 02e32;
--
Christopher Lamb
More information about the cfe-dev
mailing list