[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / c-c++-common / pr57371-1.c
blob1bac81184060be54bc769e5a4724f30c96bc509d
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-original" } */
4 #include <limits.h>
6 /* Original testcase from PR. */
8 int foo1 (short x) {
9 return (double) x != 0;
10 /* { dg-final { scan-tree-dump "return (<retval> = )?x != 0" "original" } } */
13 int foo2 (short x) {
14 return (float) x != 0;
15 /* { dg-final { scan-tree-dump "return (<retval> = )?x != 0" "original" } } */
18 int foo3 (int x) {
19 return (double) x != 0;
20 /* { dg-final { scan-tree-dump "return (<retval> = )?x != 0" "original" } } */
23 /* Tests when RHS is within range of integer type. */
25 void in_range (unsigned short x)
28 volatile int in_range_1;
29 in_range_1 = (float) x > 100.0f;
30 /* { dg-final { scan-tree-dump "in_range_1 = x > 100" "original" } } */
34 volatile int in_range_2;
35 in_range_2 = (float) x < 100.0f;
36 /* { dg-final { scan-tree-dump "in_range_2 = x <= 99" "original" } } */
40 volatile int in_range_3;
41 in_range_3 = (float) x > 100.5f;
42 /* { dg-final { scan-tree-dump "in_range_3 = x (>= 101|> 100)" "original" } } */
46 volatile int in_range_4;
47 in_range_4 = (float) x < 100.5f;
48 /* { dg-final { scan-tree-dump "in_range_4 = x <= 100" "original" } } */
52 volatile int in_range_5;
53 in_range_5 = (float) x == 100.0f;
54 /* { dg-final { scan-tree-dump "in_range_5 = x == 100" "original" } } */
58 volatile int in_range_6;
59 in_range_6 = (float) x != 100.0f;
60 /* { dg-final { scan-tree-dump "in_range_6 = x != 100" "original" } } */
64 volatile int in_range_7;
65 in_range_7 = (float) x == 100.5f;
66 /* { dg-final { scan-tree-dump "in_range_7 = 0" "original" } } */
70 volatile int in_range_8;
71 in_range_8 = (float) x != 100.5f;
72 /* { dg-final { scan-tree-dump "in_range_8 = 1" "original" } } */
76 /* Tests for cases where RHS is out of range of integer type. */
78 void out_range (unsigned short x)
81 volatile int out_range_1;
82 out_range_1 = (float) x > -100.5f;
83 /* { dg-final { scan-tree-dump "out_range_1 = 1" "original" } } */
87 volatile int out_range_2;
88 out_range_2 = (float) x >= -100.5f;
89 /* { dg-final { scan-tree-dump "out_range_2 = 1" "original" } } */
93 volatile int out_range_3;
94 out_range_3 = (float) x < -100.5f;
95 /* { dg-final { scan-tree-dump "out_range_3 = 0" "original" } } */
99 volatile int out_range_4;
100 out_range_4 = (float) x <= -100.5f;
101 /* { dg-final { scan-tree-dump "out_range_4 = 0" "original" } } */
105 volatile int out_range_5;
106 out_range_5 = (float) x == -100.5f;
107 /* { dg-final { scan-tree-dump "out_range_5 = 0" "original" } } */
111 volatile int out_range_6;
112 out_range_6 = (float) x != -100.5f;
113 /* { dg-final { scan-tree-dump "out_range_6 = 1" "original" } } */
117 /* Tests when RHS is at boundary of integer type. */
119 void lo_bounds (unsigned short x)
122 volatile int lo_bounds_1;
123 lo_bounds_1 = (float) x > 0x0;
124 /* { dg-final { scan-tree-dump "lo_bounds_1 = x (>|!=) 0" "original" } } */
128 volatile int lo_bounds_2;
129 lo_bounds_2 = (float) x >= 0x0;
130 /* { dg-final { scan-tree-dump "lo_bounds_2 = 1" "original" } } */
134 volatile int lo_bounds_3;
135 lo_bounds_3 = (float) x < 0x0;
136 /* { dg-final { scan-tree-dump "lo_bounds_3 = 0" "original" } } */
140 volatile int lo_bounds_4;
141 lo_bounds_4 = (float) x <= 0x0;
142 /* { dg-final { scan-tree-dump "lo_bounds_4 = x (<=|==) 0" "original" } } */
146 volatile int lo_bounds_5;
147 lo_bounds_5 = (float) x > 0x0 - 0.5f;
148 /* { dg-final { scan-tree-dump "lo_bounds_5 = 1" "original" } } */
152 volatile int lo_bounds_6;
153 lo_bounds_6 = (float) x >= 0x0 - 0.5f;
154 /* { dg-final { scan-tree-dump "lo_bounds_6 = 1" "original" } } */
158 volatile int lo_bounds_7;
159 lo_bounds_7 = (float) x < 0x0 - 0.5f;
160 /* { dg-final { scan-tree-dump "lo_bounds_7 = 0" "original" } } */
164 volatile int lo_bounds_8;
165 lo_bounds_8 = (float) x <= 0x0 - 0.5f;
166 /* { dg-final { scan-tree-dump "lo_bounds_8 = 0" "original" } } */
170 volatile int lo_bounds_9;
171 lo_bounds_9 = (float) x > 0x0 + 0.5f;
172 /* { dg-final { scan-tree-dump "lo_bounds_9 = x (>= 1|!= 0)" "original" } } */
176 volatile int lo_bounds_10;
177 lo_bounds_10 = (float) x >= 0x0 + 0.5f;
178 /* { dg-final { scan-tree-dump "lo_bounds_10 = x (>= 1|!= 0)" "original" } } */
182 volatile int lo_bounds_11;
183 lo_bounds_11 = (float) x < 0x0 + 0.5f;
184 /* { dg-final { scan-tree-dump "lo_bounds_11 = x (<=|==) 0" "original" } } */
188 volatile int lo_bounds_12;
189 lo_bounds_12 = (float) x <= 0x0 + 0.5f;
190 /* { dg-final { scan-tree-dump "lo_bounds_12 = x (<=|==) 0" "original" } } */
194 void hi_bounds (unsigned short x)
197 volatile int hi_bounds_1;
198 hi_bounds_1 = (float) x > USHRT_MAX;
199 /* { dg-final { scan-tree-dump "hi_bounds_1 = 0" "original" } } */
203 volatile int hi_bounds_2;
204 hi_bounds_2 = (float) x >= USHRT_MAX;
205 /* { dg-final { scan-tree-dump "hi_bounds_2 = x (>=|==) 65535" "original" } } */
209 volatile int hi_bounds_3;
210 hi_bounds_3 = (float) x < USHRT_MAX;
211 /* { dg-final { scan-tree-dump "hi_bounds_3 = x (<|!=) 65535" "original" } } */
215 volatile int hi_bounds_4;
216 hi_bounds_4 = (float) x <= USHRT_MAX;
217 /* { dg-final { scan-tree-dump "hi_bounds_4 = 1" "original" } } */
221 volatile int hi_bounds_5;
222 hi_bounds_5 = (float) x > USHRT_MAX - 0.5f;
223 /* { dg-final { scan-tree-dump "hi_bounds_5 = x (>=|==) 65535" "original" } } */
227 volatile int hi_bounds_6;
228 hi_bounds_6 = (float) x >= USHRT_MAX - 0.5f;
229 /* { dg-final { scan-tree-dump "hi_bounds_6 = x (>=|==) 65535" "original" } } */
233 volatile int hi_bounds_7;
234 hi_bounds_7 = (float) x < USHRT_MAX - 0.5f;
235 /* { dg-final { scan-tree-dump "hi_bounds_7 = x (<= 65534|!= 65535)" "original" } } */
239 volatile int hi_bounds_8;
240 hi_bounds_8 = (float) x <= USHRT_MAX - 0.5f;
241 /* { dg-final { scan-tree-dump "hi_bounds_8 = x (<= 65534|!= 65535)" "original" } } */
245 volatile int hi_bounds_9;
246 hi_bounds_9 = (float) x > USHRT_MAX + 0.5f;
247 /* { dg-final { scan-tree-dump "hi_bounds_9 = 0" "original" } } */
251 volatile int hi_bounds_10;
252 hi_bounds_10 = (float) x >= USHRT_MAX + 0.5f;
253 /* { dg-final { scan-tree-dump "hi_bounds_10 = 0" "original" } } */
257 volatile int hi_bounds_11;
258 hi_bounds_11 = (float) x < USHRT_MAX + 0.5f;
259 /* { dg-final { scan-tree-dump "hi_bounds_11 = 1" "original" } } */
263 volatile int hi_bounds_12;
264 hi_bounds_12 = (float) x <= USHRT_MAX + 0.5f;
265 /* { dg-final { scan-tree-dump "hi_bounds_12 = 1" "original" } } */
269 /* Tests with non-finite float consts. */
271 void nonfinite (unsigned short x)
273 #define INFINITY __builtin_inff ()
276 volatile int nonfinite_1;
277 nonfinite_1 = (float) x > INFINITY;
278 /* { dg-final { scan-tree-dump "nonfinite_1 = 0" "original" } } */
282 volatile int nonfinite_2;
283 nonfinite_2 = (float) x >= INFINITY;
284 /* { dg-final { scan-tree-dump "nonfinite_2 = 0" "original" } } */
288 volatile int nonfinite_3;
289 nonfinite_3 = (float) x < INFINITY;
290 /* { dg-final { scan-tree-dump "nonfinite_3 = 1" "original" } } */
294 volatile int nonfinite_4;
295 nonfinite_4 = (float) x <= INFINITY;
296 /* { dg-final { scan-tree-dump "nonfinite_4 = 1" "original" } } */
300 volatile int nonfinite_5;
301 nonfinite_5 = (float) x > -INFINITY;
302 /* { dg-final { scan-tree-dump "nonfinite_5 = 1" "original" } } */
306 volatile int nonfinite_6;
307 nonfinite_6 = (float) x >= -INFINITY;
308 /* { dg-final { scan-tree-dump "nonfinite_6 = 1" "original" } } */
312 volatile int nonfinite_7;
313 nonfinite_7 = (float) x < -INFINITY;
314 /* { dg-final { scan-tree-dump "nonfinite_7 = 0" "original" } } */
318 volatile int nonfinite_8;
319 nonfinite_8 = (float) x <= -INFINITY;
320 /* { dg-final { scan-tree-dump "nonfinite_8 = 0" "original" } } */
323 #define QNAN __builtin_nanf ("0")
325 /* Even for qNaNs, only == and != are quiet. */
328 volatile int nonfinite_9;
329 nonfinite_9 = (float) x == QNAN;
330 /* { dg-final { scan-tree-dump "nonfinite_9 = 0" "original" } } */
334 volatile int nonfinite_10;
335 nonfinite_10 = (float) x != QNAN;
336 /* { dg-final { scan-tree-dump "nonfinite_10 = 1" "original" } } */
340 /* { dg-final { scan-tree-dump-not "\\(float\\)" "original" } } */
341 /* { dg-final { scan-tree-dump-not "\\(double\\)" "original" } } */