annotate clang/test/Sema/warn-double-promotion.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -verify -fsyntax-only %s -Wdouble-promotion
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 float ReturnFloatFromDouble(double d) {
anatofuz
parents:
diff changeset
4 return d;
anatofuz
parents:
diff changeset
5 }
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 float ReturnFloatFromLongDouble(long double ld) {
anatofuz
parents:
diff changeset
8 return ld;
anatofuz
parents:
diff changeset
9 }
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 double ReturnDoubleFromLongDouble(long double ld) {
anatofuz
parents:
diff changeset
12 return ld;
anatofuz
parents:
diff changeset
13 }
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 double ReturnDoubleFromFloat(float f) {
anatofuz
parents:
diff changeset
16 return f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
anatofuz
parents:
diff changeset
17 }
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 long double ReturnLongDoubleFromFloat(float f) {
anatofuz
parents:
diff changeset
20 return f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
anatofuz
parents:
diff changeset
21 }
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 long double ReturnLongDoubleFromDouble(double d) {
anatofuz
parents:
diff changeset
24 return d; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
anatofuz
parents:
diff changeset
25 }
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 void Assignment(float f, double d, long double ld) {
anatofuz
parents:
diff changeset
28 d = f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
anatofuz
parents:
diff changeset
29 ld = f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
anatofuz
parents:
diff changeset
30 ld = d; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
anatofuz
parents:
diff changeset
31 f = d;
anatofuz
parents:
diff changeset
32 f = ld;
anatofuz
parents:
diff changeset
33 d = ld;
anatofuz
parents:
diff changeset
34 }
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 extern void DoubleParameter(double);
anatofuz
parents:
diff changeset
37 extern void LongDoubleParameter(long double);
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 void ArgumentPassing(float f, double d) {
anatofuz
parents:
diff changeset
40 DoubleParameter(f); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
anatofuz
parents:
diff changeset
41 LongDoubleParameter(f); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
anatofuz
parents:
diff changeset
42 LongDoubleParameter(d); // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
anatofuz
parents:
diff changeset
43 }
anatofuz
parents:
diff changeset
44
anatofuz
parents:
diff changeset
45 void BinaryOperator(float f, double d, long double ld) {
anatofuz
parents:
diff changeset
46 f = f * d; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
anatofuz
parents:
diff changeset
47 f = d * f; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
anatofuz
parents:
diff changeset
48 f = f * ld; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
anatofuz
parents:
diff changeset
49 f = ld * f; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
anatofuz
parents:
diff changeset
50 d = d * ld; // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
anatofuz
parents:
diff changeset
51 d = ld * d; // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
anatofuz
parents:
diff changeset
52 }
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 void MultiplicationAssignment(float f, double d, long double ld) {
anatofuz
parents:
diff changeset
55 d *= f; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
anatofuz
parents:
diff changeset
56 ld *= f; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
anatofuz
parents:
diff changeset
57 ld *= d; // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 // FIXME: These cases should produce warnings as above.
anatofuz
parents:
diff changeset
60 f *= d;
anatofuz
parents:
diff changeset
61 f *= ld;
anatofuz
parents:
diff changeset
62 d *= ld;
anatofuz
parents:
diff changeset
63 }
anatofuz
parents:
diff changeset
64
anatofuz
parents:
diff changeset
65 // FIXME: As with a binary operator, the operands to the conditional operator are
anatofuz
parents:
diff changeset
66 // converted to a common type and should produce a warning.
anatofuz
parents:
diff changeset
67 void ConditionalOperator(float f, double d, long double ld, int i) {
anatofuz
parents:
diff changeset
68 f = i ? f : d;
anatofuz
parents:
diff changeset
69 f = i ? d : f;
anatofuz
parents:
diff changeset
70 f = i ? f : ld;
anatofuz
parents:
diff changeset
71 f = i ? ld : f;
anatofuz
parents:
diff changeset
72 d = i ? d : ld;
anatofuz
parents:
diff changeset
73 d = i ? ld : d;
anatofuz
parents:
diff changeset
74 }