[cfe-dev] Support floating point literals with exponent but no point

Chris Lattner clattner at apple.com
Sun Nov 25 22:09:53 PST 2007


On Nov 25, 2007, at 6:58 PM, Christopher Lamb wrote:

> GCC allows literals of the form "1e-16f" which clang currently
> rejects. The following patch is proposed:

Looks good to me, please commit.  Also, please verify that the  
constants come out right in the -emit-llvm or ast-dump output, thanks  
Christopher!

-Chris

>
> 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
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list