| 1 |
/* Excess precision tests. Test C11 semantics for conversions from |
| 2 |
integers to floating point: no excess precision for either explicit |
| 3 |
conversions, but excess precision for implicit conversions. */ |
| 4 |
/* { dg-do run } */ |
| 5 |
/* { dg-options "-std=c11 -mfpmath=387 -fexcess-precision=standard" } */ |
| 6 |
|
| 7 |
#ifdef __cplusplus |
| 8 |
extern "C" { |
| 9 |
#endif |
| 10 |
extern void abort (void); |
| 11 |
extern void exit (int); |
| 12 |
#ifdef __cplusplus |
| 13 |
} |
| 14 |
#endif |
| 15 |
|
| 16 |
int |
| 17 |
main (void) |
| 18 |
{ |
| 19 |
float f = 1.0f; |
| 20 |
int i; |
| 21 |
|
| 22 |
i = 0x10001234; |
| 23 |
if ((float) i != 0x10001240) |
| 24 |
abort (); |
| 25 |
|
| 26 |
i = 0x10001234; |
| 27 |
i += f; |
| 28 |
if (i != 0x10001235) |
| 29 |
abort (); |
| 30 |
|
| 31 |
i = 0x10001234; |
| 32 |
i += 1.0f; |
| 33 |
if (i != 0x10001235) |
| 34 |
abort (); |
| 35 |
|
| 36 |
i = 0x10001234; |
| 37 |
i = i + f; |
| 38 |
if (i != 0x10001235) |
| 39 |
abort (); |
| 40 |
|
| 41 |
i = 0x10001234; |
| 42 |
i = i + 1.0f; |
| 43 |
if (i != 0x10001235) |
| 44 |
abort (); |
| 45 |
|
| 46 |
i = 0x10001235; |
| 47 |
i = (1 ? i : 1.0f); |
| 48 |
if (i != 0x10001235) |
| 49 |
abort (); |
| 50 |
|
| 51 |
i = 0x10001235; |
| 52 |
i = (1 ? i : f); |
| 53 |
if (i != 0x10001235) |
| 54 |
abort (); |
| 55 |
|
| 56 |
i = 0x10001235; |
| 57 |
i = (0 ? 1.0f :i); |
| 58 |
if (i != 0x10001235) |
| 59 |
abort (); |
| 60 |
|
| 61 |
i = 0x10001235; |
| 62 |
i = (0 ? f : i); |
| 63 |
if (i != 0x10001235) |
| 64 |
abort (); |
| 65 |
|
| 66 |
exit (0); |
| 67 |
} |