| 1 |
/* PR middle-end/56917 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-fsanitize=undefined -fno-sanitize-recover=undefined" } */ |
| 4 |
|
| 5 |
#define INT_MIN (-__INT_MAX__ - 1) |
| 6 |
#define LONG_MIN (-__LONG_MAX__ - 1L) |
| 7 |
#define LLONG_MIN (-__LONG_LONG_MAX__ - 1LL) |
| 8 |
|
| 9 |
int __attribute__ ((noinline,noclone)) |
| 10 |
fn1 (unsigned int u) |
| 11 |
{ |
| 12 |
return (-(int) (u - 1U)) - 1; |
| 13 |
} |
| 14 |
|
| 15 |
long __attribute__ ((noinline,noclone)) |
| 16 |
fn2 (unsigned long int ul) |
| 17 |
{ |
| 18 |
return (-(long) (ul - 1UL)) - 1L; |
| 19 |
} |
| 20 |
|
| 21 |
long long __attribute__ ((noinline,noclone)) |
| 22 |
fn3 (unsigned long long int ull) |
| 23 |
{ |
| 24 |
return (-(long long) (ull - 1ULL)) - 1LL; |
| 25 |
} |
| 26 |
|
| 27 |
int |
| 28 |
main (void) |
| 29 |
{ |
| 30 |
if (fn1 (__INT_MAX__ + 1U) != INT_MIN |
| 31 |
|| fn2 (__LONG_MAX__ + 1UL) != LONG_MIN |
| 32 |
|| fn3 (__LONG_LONG_MAX__ + 1ULL) != LLONG_MIN) |
| 33 |
__builtin_abort (); |
| 34 |
} |