| 1 |
/* PR c/19606 |
| 2 |
The C front end used to shorten the type of a division to a type |
| 3 |
that does not preserve the semantics of the original computation. |
| 4 |
Make sure that won't happen. */ |
| 5 |
|
| 6 |
void abort (void); |
| 7 |
void exit (int); |
| 8 |
|
| 9 |
signed char a = -4; |
| 10 |
|
| 11 |
int |
| 12 |
foo (void) |
| 13 |
{ |
| 14 |
return ((unsigned int) (signed int) a) / 2LL; |
| 15 |
} |
| 16 |
|
| 17 |
int |
| 18 |
bar (void) |
| 19 |
{ |
| 20 |
return ((unsigned int) (signed int) a) % 5LL; |
| 21 |
} |
| 22 |
|
| 23 |
int |
| 24 |
main (void) |
| 25 |
{ |
| 26 |
int r; |
| 27 |
|
| 28 |
r = foo (); |
| 29 |
if (r != ((unsigned int) (signed int) (signed char) -4) / 2LL) |
| 30 |
abort (); |
| 31 |
|
| 32 |
r = bar (); |
| 33 |
if (r != ((unsigned int) (signed int) (signed char) -4) % 5LL) |
| 34 |
abort (); |
| 35 |
|
| 36 |
exit (0); |
| 37 |
} |