1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -verify -fsyntax-only %s -Wdouble-promotion
3 float ReturnFloatFromDouble(double d
) {
7 float ReturnFloatFromLongDouble(long double ld
) {
11 double ReturnDoubleFromLongDouble(long double ld
) {
15 double ReturnDoubleFromFloat(float f
) {
16 return f
; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
19 long double ReturnLongDoubleFromFloat(float f
) {
20 return f
; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
23 long double ReturnLongDoubleFromDouble(double d
) {
24 return d
; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
27 void Assignment(float f
, double d
, long double ld
) {
28 d
= f
; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
29 ld
= f
; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
30 ld
= d
; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
36 extern void DoubleParameter(double);
37 extern void LongDoubleParameter(long double);
39 void ArgumentPassing(float f
, double d
) {
40 DoubleParameter(f
); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
41 LongDoubleParameter(f
); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
42 LongDoubleParameter(d
); // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
45 void BinaryOperator(float f
, double d
, long double ld
) {
46 f
= f
* d
; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
47 f
= d
* f
; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
48 f
= f
* ld
; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
49 f
= ld
* f
; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
50 d
= d
* ld
; // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
51 d
= ld
* d
; // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
54 void MultiplicationAssignment(float f
, double d
, long double ld
) {
55 d
*= f
; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
56 ld
*= f
; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
57 ld
*= d
; // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
59 // FIXME: These cases should produce warnings as above.
65 // FIXME: As with a binary operator, the operands to the conditional operator are
66 // converted to a common type and should produce a warning.
67 void ConditionalOperator(float f
, double d
, long double ld
, int i
) {