c++: Fix ICE with #embed/RAW_DATA_CST after list conversion [PR118671]
[official-gcc.git] / gcc / testsuite / gcc.dg / dfp / c23-decimal64x-1.c
blob6a6f815df16d865433059cc2b4d1b6219853c0b9
1 /* Test _Decimal64x in C23 mode. */
2 /* { dg-do run } */
3 /* { dg-options "-std=c23 -pedantic-errors" } */
5 int a = (int) 1.1D64x;
6 int b = (int) 2.d64x;
7 _Decimal64x c = 1;
9 #define expr_has_type(e, t) _Generic (e, default : 0, t : 1)
10 static_assert (expr_has_type (1.1D64x, _Decimal64x));
11 static_assert (expr_has_type (2.d64x, _Decimal64x));
12 static_assert (expr_has_type (.33D64x, _Decimal64x));
13 static_assert (expr_has_type (2e1d64x, _Decimal64x));
14 static_assert (expr_has_type (.3e2D64x, _Decimal64x));
15 static_assert (expr_has_type (4.5e3d64x, _Decimal64x));
16 static_assert (expr_has_type (5.e0D64x, _Decimal64x));
17 static_assert (expr_has_type (1e+2d64x, _Decimal64x));
18 static_assert (expr_has_type (1000e-3D64x, _Decimal64x));
19 static_assert (expr_has_type (__DEC64X_MIN__, _Decimal64x));
20 static_assert (expr_has_type (__DEC64X_MAX__, _Decimal64x));
21 static_assert (expr_has_type (__DEC64X_EPSILON__, _Decimal64x));
22 static_assert (expr_has_type (__DEC64X_SUBNORMAL_MIN__, _Decimal64x));
23 #if __DEC64X_MANT_DIG__ == __DEC128_MANT_DIG__ \
24 && __DEC64X_MAX_EXP__ == __DEC128_MAX_EXP__
25 static_assert (expr_has_type (1.1D32 + 1.1D64x, _Decimal64x));
26 static_assert (expr_has_type (1.1D64 + 1.1D64x, _Decimal64x));
27 static_assert (expr_has_type (1.1D64x + 1.1D64x, _Decimal64x));
28 static_assert (expr_has_type (1.1D128 + 1.1D64x, _Decimal128));
29 static_assert (expr_has_type (1 + 1.1D64x, _Decimal64x));
30 static_assert (expr_has_type (1U + 1.1D64x, _Decimal64x));
31 static_assert (expr_has_type (1L + 1.1D64x, _Decimal64x));
32 static_assert (expr_has_type (1UL + 1.1D64x, _Decimal64x));
33 static_assert (expr_has_type (1LL + 1.1D64x, _Decimal64x));
34 static_assert (expr_has_type (1ULL + 1.1D64x, _Decimal64x));
35 static_assert (expr_has_type (1.1D64x + 1.1D32, _Decimal64x));
36 static_assert (expr_has_type (1.1D64x + 1.1D64, _Decimal64x));
37 static_assert (expr_has_type (1.1D64x + 1.1D64x, _Decimal64x));
38 static_assert (expr_has_type (1.1D64x + 1.1D128, _Decimal128));
39 static_assert (expr_has_type (1.1D64x + 1, _Decimal64x));
40 static_assert (expr_has_type (1.1D64x + 1U, _Decimal64x));
41 static_assert (expr_has_type (1.1D64x + 1L, _Decimal64x));
42 static_assert (expr_has_type (1.1D64x + 1UL, _Decimal64x));
43 static_assert (expr_has_type (1.1D64x + 1LL, _Decimal64x));
44 static_assert (expr_has_type (1.1D64x + 1ULL, _Decimal64x));
45 #endif
47 _Decimal64x
48 foo (_Decimal64x x, _Decimal64x y)
50 return x + y;
53 int
54 main ()
56 #if __DEC64X_MANT_DIG__ == __DEC128_MANT_DIG__ \
57 && __DEC64X_MAX_EXP__ == __DEC128_MAX_EXP__
58 if (1.1D64x != 1.1dl
59 || 2.d64x != 2.dl
60 || .33D64x != .33dl
61 || 2e1d64x != 2e1dl
62 || .3e2D64x != .3e2dl
63 || 4.5e3d64x != 4.5e3dl
64 || 5.e0D64x != 5.e0dl
65 || 1e+2d64x != 1e+2dl
66 || 1000e-3D64x != 1000e-3dl
67 || __DEC64X_MIN__ != __DEC128_MIN__
68 || __DEC64X_MAX__ != __DEC128_MAX__
69 || __DEC64X_EPSILON__ != __DEC128_EPSILON__
70 || __DEC64X_SUBNORMAL_MIN__ != __DEC128_SUBNORMAL_MIN__
71 || foo (0.5d64x, 0.5D64x) != 1.D64x)
72 __builtin_abort ();
73 #endif