diff options
author | Chris Lattner <sabre@nondot.org> | 2008-07-25 18:18:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-07-25 18:18:34 +0000 |
commit | c94ad4abcb928049ffb8010ae0b9215af77190b1 (patch) | |
tree | f8050fbcef4de61042a6764ff917b8301d772ed4 /clang/lib/Lex/LiteralSupport.cpp | |
parent | 83ec24501ef41fecac0b000c49b2c4ca644aea74 (diff) | |
download | bcm5719-llvm-c94ad4abcb928049ffb8010ae0b9215af77190b1.tar.gz bcm5719-llvm-c94ad4abcb928049ffb8010ae0b9215af77190b1.zip |
In c89 mode accept hex fp constants as an extension:
t2.c:1:17: warning: hexadecimal floating constants are a C99 feature
long double d = 0x0.0000003ffffffff00000p-16357L;
^
instead of emitting a weird error message that doesn't make sense:
t2.c:1:41: error: hexadecimal floating constants require an exponent
long double d = 0x0.0000003ffffffff00000p-16357L;
^
rdar://6096838
llvm-svn: 54035
Diffstat (limited to 'clang/lib/Lex/LiteralSupport.cpp')
-rw-r--r-- | clang/lib/Lex/LiteralSupport.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 6c91e0e82d0..fc90b4b00ef 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -354,18 +354,21 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { } // A binary exponent can appear with or with a '.'. If dotted, the // binary exponent is required. - if ((*s == 'p' || *s == 'P') && PP.getLangOptions().HexFloats) { + if (*s == 'p' || *s == 'P') { const char *Exponent = s; s++; saw_exponent = true; if (*s == '+' || *s == '-') s++; // sign const char *first_non_digit = SkipDigits(s); - if (first_non_digit != s) { - s = first_non_digit; - } else { + if (first_non_digit == s) { Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-ThisTokBegin), diag::err_exponent_has_no_digits); + return; } + s = first_non_digit; + + if (!PP.getLangOptions().HexFloats) + Diag(TokLoc, diag::ext_hexconstant_invalid); } else if (saw_period) { Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin), diag::err_hexconstant_requires_exponent); |