[cfe-commits] r52846 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CodeGen/exprs.c
Chris Lattner
sabre at nondot.org
Fri Jun 27 15:48:56 PDT 2008
Author: lattner
Date: Fri Jun 27 17:48:56 2008
New Revision: 52846
URL: http://llvm.org/viewvc/llvm-project?rev=52846&view=rev
Log:
Fix a bug where we didn't promote 'const float' (or typedefs) to
double in some places.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGen/exprs.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=52846&r1=52845&r2=52846&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jun 27 17:48:56 2008
@@ -1045,10 +1045,12 @@
QualType Ty = Expr->getType();
assert(!Ty.isNull() && "DefaultArgumentPromotion - missing type");
- if (Ty == Context.FloatTy)
- ImpCastExprToType(Expr, Context.DoubleTy);
- else
- UsualUnaryConversions(Expr);
+ // If this is a 'float' (CVR qualified or typedef) promote to double.
+ if (const BuiltinType *BT = Ty->getAsBuiltinType())
+ if (BT->getKind() == BuiltinType::Float)
+ return ImpCastExprToType(Expr, Context.DoubleTy);
+
+ UsualUnaryConversions(Expr);
}
/// DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
Modified: cfe/trunk/test/CodeGen/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exprs.c?rev=52846&r1=52845&r2=52846&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/exprs.c (original)
+++ cfe/trunk/test/CodeGen/exprs.c Fri Jun 27 17:48:56 2008
@@ -1,4 +1,4 @@
-// RUN: clang %s -emit-llvm
+// RUN: clang %s -emit-llvm -o -
// PR1895
// sizeof function
@@ -34,3 +34,8 @@
t2 = __alignof__(test4());
}
+// 'const float' promotes to double in varargs.
+int test5(const float x, float float_number) {
+ return __builtin_isless(x, float_number);
+}
+
More information about the cfe-commits
mailing list