Let tree_single_nonzero_warnv_p use range information
[official-gcc.git] / gcc / testsuite / gcc.dg / pr38364.c
blob6b22e9d78e986870ed11270a1f026bb0ab8b21ac
1 /* PR middle-end/38364 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -ftrapv" } */
4 /* { dg-require-effective-target trapping } */
6 extern void abort (void);
8 static inline short
9 f1 (short x, short y)
11 if (x > 0)
13 if (y > 0)
15 if (x > __SHRT_MAX__ / y)
16 return x;
18 else if (y < (-__SHRT_MAX__ - 1) / x)
19 return x;
21 else
23 if (y > 0)
25 if (x < (-__SHRT_MAX__ - 1) / y)
26 return x;
28 else if (x != 0 && y < __SHRT_MAX__ / x)
29 return x;
31 return x * y;
34 static inline signed char
35 f2 (signed char x, signed char y)
37 if (((x ^ y) & (((x ^ ((x ^ y) & (1 << (__CHAR_BIT__ - 1)))) - y) ^ y)) < 0)
38 return x;
39 return x - y;
42 unsigned int v;
44 int
45 f3 (int x, unsigned int y)
47 f1 (1, 1);
48 return 1;
51 int
52 f4 (unsigned short x)
54 v = x;
55 return 1;
58 int
59 f5 (int x)
61 if (f2 (x, 1))
62 f1 (1, f4 (1));
63 return x;
66 int
67 f6 (unsigned int x)
69 f4 (x < (1 != f5 (0)));
70 return x;
73 int
74 main (void)
76 f6 (1);
77 if (v != 0)
78 abort ();
79 return 0;