]> granicus.if.org Git - clang/commitdiff
Do unary conversions on vararg arguments and *then* special-case float.
authorJohn McCall <rjmccall@apple.com>
Mon, 6 Dec 2010 18:36:11 +0000 (18:36 +0000)
committerJohn McCall <rjmccall@apple.com>
Mon, 6 Dec 2010 18:36:11 +0000 (18:36 +0000)
Fixes PR8742.

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

lib/Sema/SemaExpr.cpp
test/CodeGenObjC/property.m

index 8eed9b10e0c135fa81b92fa5de58d9401876f1b3..bc8a7527c85bb183bde54cfe4a95e829269fb5fb 100644 (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
index fe8737e917605706d7d2b4dfd456dc3fdd97996e..dd0786eb30ee0ec4d24426089fcdf7af36eb1e70 100644 (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);
+}