From: Chris Lattner Date: Fri, 27 Jun 2008 22:48:56 +0000 (+0000) Subject: Fix a bug where we didn't promote 'const float' (or typedefs) to X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3cc5e5b5268d7359c818ca5a2b62a339923020c4;p=clang Fix a bug where we didn't promote 'const float' (or typedefs) to double in some places. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52846 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index e84971062e..7089919083 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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). diff --git a/test/CodeGen/exprs.c b/test/CodeGen/exprs.c index b4384ee0c2..f1c9a5d73f 100644 --- a/test/CodeGen/exprs.c +++ b/test/CodeGen/exprs.c @@ -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); +} +