Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.dg / dfp / union-init.c
blob6896ece99b202b12b9d17491ba7ef52c2d3457a8
1 /* Cast to union is a GNU C extension. */
3 #include "dfp-dbg.h"
5 union u
7 _Decimal128 d128;
8 double d;
9 };
11 union n
13 double d;
14 _Decimal64 d64;
17 int main ()
19 static union u u1 = { 0.0dl };
20 static union u u2 = { 4.2dl };
21 static union u u4 = { 0.0 };
23 static union n n1 = { 2.2dd };
24 static union n n2 = { 3.25 };
26 _Decimal128 d128;
27 _Decimal64 d64;
28 double d;
30 if (u1.d128 != 0.0dl)
31 FAILURE
33 if (u2.d128 != 4.2dl)
34 FAILURE
36 /* cast decimal floating point to union type. */
37 d128 = 1.23dl;
38 d64 = 4.56dd;
39 d = 3.25;
41 u4 = (union u) d128;
42 if (u4.d128 != 1.23dl)
43 FAILURE
45 u4 = (union u) d;
46 if (u4.d != 3.25)
47 FAILURE
49 n1 = (union n) d64;
50 if (n1.d64 != 4.56dd)
51 FAILURE
53 n1 = (union n)d;
54 if (n1.d != 3.25)
55 FAILURE
57 FINISH