[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / warn-double-promotion.c
blob5742a4fb3cbd4bfd4a6543b889cc920ce52fe9de
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -verify -fsyntax-only %s -Wdouble-promotion
3 float ReturnFloatFromDouble(double d) {
4 return d;
7 float ReturnFloatFromLongDouble(long double ld) {
8 return ld;
11 double ReturnDoubleFromLongDouble(long double ld) {
12 return 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'}}
31 f = d;
32 f = ld;
33 d = ld;
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.
60 f *= d;
61 f *= ld;
62 d *= ld;
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) {
68 f = i ? f : d;
69 f = i ? d : f;
70 f = i ? f : ld;
71 f = i ? ld : f;
72 d = i ? d : ld;
73 d = i ? ld : d;