| 1 |
/* PR middle-end/38364 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-O2 -ftrapv" } */ |
| 4 |
/* { dg-require-effective-target trapping } */ |
| 5 |
|
| 6 |
extern void abort (void); |
| 7 |
|
| 8 |
static inline short |
| 9 |
f1 (short x, short y) |
| 10 |
{ |
| 11 |
if (x > 0) |
| 12 |
{ |
| 13 |
if (y > 0) |
| 14 |
{ |
| 15 |
if (x > __SHRT_MAX__ / y) |
| 16 |
return x; |
| 17 |
} |
| 18 |
else if (y < (-__SHRT_MAX__ - 1) / x) |
| 19 |
return x; |
| 20 |
} |
| 21 |
else |
| 22 |
{ |
| 23 |
if (y > 0) |
| 24 |
{ |
| 25 |
if (x < (-__SHRT_MAX__ - 1) / y) |
| 26 |
return x; |
| 27 |
} |
| 28 |
else if (x != 0 && y < __SHRT_MAX__ / x) |
| 29 |
return x; |
| 30 |
} |
| 31 |
return x * y; |
| 32 |
} |
| 33 |
|
| 34 |
static inline signed char |
| 35 |
f2 (signed char x, signed char y) |
| 36 |
{ |
| 37 |
if (((x ^ y) & (((x ^ ((x ^ y) & (1 << (__CHAR_BIT__ - 1)))) - y) ^ y)) < 0) |
| 38 |
return x; |
| 39 |
return x - y; |
| 40 |
} |
| 41 |
|
| 42 |
unsigned int v; |
| 43 |
|
| 44 |
int |
| 45 |
f3 (int x, unsigned int y) |
| 46 |
{ |
| 47 |
f1 (1, 1); |
| 48 |
return 1; |
| 49 |
} |
| 50 |
|
| 51 |
int |
| 52 |
f4 (unsigned short x) |
| 53 |
{ |
| 54 |
v = x; |
| 55 |
return 1; |
| 56 |
} |
| 57 |
|
| 58 |
int |
| 59 |
f5 (int x) |
| 60 |
{ |
| 61 |
if (f2 (x, 1)) |
| 62 |
f1 (1, f4 (1)); |
| 63 |
return x; |
| 64 |
} |
| 65 |
|
| 66 |
int |
| 67 |
f6 (unsigned int x) |
| 68 |
{ |
| 69 |
f4 (x < (1 != f5 (0))); |
| 70 |
return x; |
| 71 |
} |
| 72 |
|
| 73 |
int |
| 74 |
main (void) |
| 75 |
{ |
| 76 |
f6 (1); |
| 77 |
if (v != 0) |
| 78 |
abort (); |
| 79 |
return 0; |
| 80 |
} |