Do unary conversions on vararg arguments and *then* special-case float.

Fixes PR8742.

llvm-svn: 121022
This commit is contained in:
John McCall 2010-12-06 18:36:11 +00:00
parent bb4a76fc95
commit 9bc2677b8c
2 changed files with 17 additions and 4 deletions

View File

@ -345,12 +345,11 @@ void Sema::DefaultArgumentPromotion(Expr *&Expr) {
QualType Ty = Expr->getType();
assert(!Ty.isNull() && "DefaultArgumentPromotion - missing type");
UsualUnaryConversions(Expr);
// If this is a 'float' (CVR qualified or typedef) promote to double.
if (Ty->isSpecificBuiltinType(BuiltinType::Float))
return ImpCastExprToType(Expr, Context.DoubleTy,
CK_FloatingCast);
UsualUnaryConversions(Expr);
return ImpCastExprToType(Expr, Context.DoubleTy, CK_FloatingCast);
}
/// DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but

View File

@ -89,3 +89,17 @@ void test3(test3_object *p) {
struct test3_struct array[1] = { p.s };
struct test3_nested agg = { p.s };
}
// PR8742
@interface Test4 {}
@property float f;
@end
// CHECK: define void @test4
void test4(Test4 *t) {
extern int test4_printf(const char *, ...);
// CHECK: [[TMP:%.*]] = call float {{.*}} @objc_msgSend
// CHECK-NEXT: [[EXT:%.*]] = fpext float [[TMP]] to double
// CHECK-NEXT: call i32 (i8*, ...)* @test4_printf(i8* {{.*}}, double [[EXT]])
// CHECK-NEXT: ret void
test4_printf("%.2f", t.f);
}