[cfe-commits] r41412 - in /cfe/trunk: Lex/LiteralSupport.cpp Lex/PPExpressions.cpp Sema/SemaExpr.cpp include/clang/Lex/LiteralSupport.h
Chris Lattner
sabre at nondot.org
Sat Aug 25 20:29:24 PDT 2007
Author: lattner
Date: Sat Aug 25 22:29:23 2007
New Revision: 41412
URL: http://llvm.org/viewvc/llvm-project?rev=41412&view=rev
Log:
1.0 is double, 1.0F is a float.
Modified:
cfe/trunk/Lex/LiteralSupport.cpp
cfe/trunk/Lex/PPExpressions.cpp
cfe/trunk/Sema/SemaExpr.cpp
cfe/trunk/include/clang/Lex/LiteralSupport.h
Modified: cfe/trunk/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/LiteralSupport.cpp?rev=41412&r1=41411&r2=41412&view=diff
==============================================================================
--- cfe/trunk/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/Lex/LiteralSupport.cpp Sat Aug 25 22:29:23 2007
@@ -202,10 +202,10 @@
s = DigitsBegin = begin;
saw_exponent = false;
saw_period = false;
- saw_float_suffix = false;
isLong = false;
isUnsigned = false;
isLongLong = false;
+ isFloat = false;
isImaginary = false;
hadError = false;
@@ -326,8 +326,8 @@
case 'f': // FP Suffix for "float"
case 'F':
if (!isFPConstant) break; // Error for integer constant.
- if (saw_float_suffix || isLong) break; // FF, LF invalid.
- saw_float_suffix = true;
+ if (isFloat || isLong) break; // FF, LF invalid.
+ isFloat = true;
continue; // Success.
case 'u':
case 'U':
@@ -338,7 +338,7 @@
case 'l':
case 'L':
if (isLong || isLongLong) break; // Cannot be repeated.
- if (saw_float_suffix) break; // LF invalid.
+ if (isFloat) break; // LF invalid.
// Check for long long. The L's need to be adjacent and the same case.
if (s+1 != ThisTokEnd && s[1] == s[0]) {
Modified: cfe/trunk/Lex/PPExpressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/PPExpressions.cpp?rev=41412&r1=41411&r2=41412&view=diff
==============================================================================
--- cfe/trunk/Lex/PPExpressions.cpp (original)
+++ cfe/trunk/Lex/PPExpressions.cpp Sat Aug 25 22:29:23 2007
@@ -161,7 +161,7 @@
if (Literal.hadError)
return true; // a diagnostic was already reported.
- if (Literal.isFloatingLiteral()) {
+ if (Literal.isFloatingLiteral() || Literal.isImaginary) {
PP.Diag(PeekTok, diag::err_pp_illegal_floating_literal);
return true;
}
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=41412&r1=41411&r2=41412&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Sat Aug 25 22:29:23 2007
@@ -221,8 +221,8 @@
return new IntegerLiteral(ResultVal, t, Tok.getLocation());
} else if (Literal.isFloatingLiteral()) {
// FIXME: handle float values > 32 (including compute the real type...).
- return new FloatingLiteral(Literal.GetFloatValue(), Context.FloatTy,
- Tok.getLocation());
+ QualType Ty = Literal.isFloat ? Context.FloatTy : Context.DoubleTy;
+ return new FloatingLiteral(Literal.GetFloatValue(), Ty, Tok.getLocation());
}
return ExprResult(true);
}
Modified: cfe/trunk/include/clang/Lex/LiteralSupport.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LiteralSupport.h?rev=41412&r1=41411&r2=41412&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/LiteralSupport.h (original)
+++ cfe/trunk/include/clang/Lex/LiteralSupport.h Sat Aug 25 22:29:23 2007
@@ -44,7 +44,6 @@
unsigned radix;
bool saw_exponent, saw_period;
- bool saw_float_suffix; // 1.0f
public:
NumericLiteralParser(const char *begin, const char *end,
@@ -53,6 +52,7 @@
bool isUnsigned;
bool isLong; // This is *not* set for long long.
bool isLongLong;
+ bool isFloat; // 1.0f
bool isImaginary; // 1.0i
bool isIntegerLiteral() const {
More information about the cfe-commits
mailing list