2015-10-17 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / c-c++-common / dfp / cast.c
blobb6585d70c8b4fbc8a4b2bae3fbd71194c5360106
1 /* C99 6.5.4 Cast operators.
2 Test valid casts involving decimal float. */
4 #include "dfp-dbg.h"
6 _Decimal32 d32;
7 _Decimal64 d64;
8 _Decimal128 d128;
10 static float f = 2.f;
11 static double d = 2.l;
13 int
14 main (void)
16 /* Casts between DFP types. */
17 d32 = 1.2df;
18 d64 = 1.2dd;
19 d128 = 1.2dl;
21 if (d32 != (_Decimal32) d64)
22 FAILURE
23 if (d32 != (_Decimal32) d128)
24 FAILURE
26 if (d64 != (_Decimal64) d32)
27 FAILURE
28 if (d64 != (_Decimal64) d128)
29 FAILURE
31 if (d128 != (_Decimal128) d32)
32 FAILURE
33 if (d128 != (_Decimal128) d64)
34 FAILURE
36 /* Casts between generic and decimal floating point types. Use a
37 value that we can assume can be represented exactly in all
38 representations. */
40 d32 = 2.0df;
41 d64 = 2.0dd;
42 d128 = 2.0dl;
44 /* To generic floating types. */
45 if ((float) d32 != 2.0f)
46 FAILURE
47 if ((double) d32 != 2.0l)
48 FAILURE
49 if ((float) d64 != 2.0f)
50 FAILURE
51 if ((double) d64 != 2.0l)
52 FAILURE
53 if ((float) d128 != 2.0f)
54 FAILURE
55 if ((double) d128 != 2.0l)
56 FAILURE
58 /* float to decimal floating types. */
59 if (d32 != (_Decimal32) f)
60 FAILURE
61 if (d64 != (_Decimal64) f)
62 FAILURE
63 if (d128 != (_Decimal128) f)
64 FAILURE
66 /* double to decimal floating types. */
67 if (d32 != (_Decimal32) d)
68 FAILURE
69 if (d64 != (_Decimal64) d)
70 FAILURE
71 if (d128 != (_Decimal128) d)
72 FAILURE
74 FINISH