]> granicus.if.org Git - clang/commitdiff
Fix a bug where we didn't promote 'const float' (or typedefs) to
authorChris Lattner <sabre@nondot.org>
Fri, 27 Jun 2008 22:48:56 +0000 (22:48 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 27 Jun 2008 22:48:56 +0000 (22:48 +0000)
double in some places.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52846 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CodeGen/exprs.c

index e84971062eda6742a0986aa5c7b944104574f61d..70899190839bf393aac404a1cf7a890529b7d83d 100644 (file)
@@ -1045,10 +1045,12 @@ void Sema::DefaultArgumentPromotion(Expr *&Expr) {
   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).
index b4384ee0c2ae3e1b03eab1653416e438f774ebb5..f1c9a5d73fa635566d8180efb7a46897f2c63343 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: clang %s -emit-llvm
+// RUN: clang %s -emit-llvm -o -
 
 // PR1895
 // sizeof function
@@ -34,3 +34,8 @@ void test4() {
   t2 = __alignof__(test4());
 }
 
+// 'const float' promotes to double in varargs.
+int test5(const float x, float float_number) {
+  return __builtin_isless(x, float_number);
+}
+