| 1 |
/* Test that DFP constants are accepted in C23 mode. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-std=c23 -pedantic-errors" } */ |
| 4 |
|
| 5 |
int a = (int) 1.1D32; |
| 6 |
int b = (int) 2.d32; |
| 7 |
int c = (int) .33D64; |
| 8 |
int d = (int) 2e1d64; |
| 9 |
int e = (int) .3e2D128; |
| 10 |
int f = (int) 4.5e3d128; |
| 11 |
int g = (int) 5.e0D32; |
| 12 |
int h = (int) 1e+2d32; |
| 13 |
int i = (int) 1000e-3D128; |
| 14 |
|
| 15 |
#define expr_has_type(e, t) _Generic (e, default : 0, t : 1) |
| 16 |
static_assert (expr_has_type (1.1D32, _Decimal32)); |
| 17 |
static_assert (expr_has_type (2.d32, _Decimal32)); |
| 18 |
static_assert (expr_has_type (.33D64, _Decimal64)); |
| 19 |
static_assert (expr_has_type (2e1d64, _Decimal64)); |
| 20 |
static_assert (expr_has_type (.3e2D128, _Decimal128)); |
| 21 |
static_assert (expr_has_type (4.5e3d128, _Decimal128)); |
| 22 |
static_assert (expr_has_type (5.e0D32, _Decimal32)); |
| 23 |
static_assert (expr_has_type (1e+2d32, _Decimal32)); |
| 24 |
static_assert (expr_has_type (1000e-3D128, _Decimal128)); |
| 25 |
|
| 26 |
int |
| 27 |
main () |
| 28 |
{ |
| 29 |
if (1.1D32 != 1.1df |
| 30 |
|| 2.d32 != 2.df |
| 31 |
|| .33D64 != .33dd |
| 32 |
|| 2e1d64 != 2e1dd |
| 33 |
|| .3e2D128 != .3e2dl |
| 34 |
|| 4.5e3d128 != 4.5e3dl |
| 35 |
|| 5.e0D32 != 5.e0df |
| 36 |
|| 1e+2d32 != 1e+2df |
| 37 |
|| 1000e-3D128 != 1000e-3dl) |
| 38 |
__builtin_abort (); |
| 39 |
} |