1 /* C99 6.5.2.2 Function calls.
2    Test structure passing and return values involving decimal floating
3    point types.  */
4 
5 #include "dfp-dbg.h"
6 
7 struct example
8 {
9   _Decimal128 d128;
10   char dummy1;
11   _Decimal64 d64;
12   char dummy2;
13   _Decimal32 d32;
14 } nums = { 1.0dl, 'a', 2.0dd, 'b', 3.0df };
15 
16 _Decimal32
d32_field(struct example s)17 d32_field (struct example s)
18 {
19   return s.d32;
20 }
21 
22 _Decimal64
d64_field(struct example s)23 d64_field (struct example s)
24 {
25   return s.d64;
26 }
27 
28 _Decimal128
d128_field(struct example s)29 d128_field (struct example s)
30 {
31   return s.d128;
32 }
33 
34 char
dummy1_field(struct example s)35 dummy1_field (struct example s)
36 {
37   return s.dummy1;
38 }
39 
40 char
dummy2_field(struct example s)41 dummy2_field (struct example s)
42 {
43   return s.dummy2;
44 }
45 
46 _Decimal32
ptr_d32_field(struct example * s)47 ptr_d32_field (struct example *s)
48 {
49   return s->d32;
50 }
51 
52 _Decimal64
ptr_d64_field(struct example * s)53 ptr_d64_field (struct example *s)
54 {
55   return s->d64;
56 }
57 
58 _Decimal128
ptr_d128_field(struct example * s)59 ptr_d128_field (struct example *s)
60 {
61   return s->d128;
62 }
63 
64 char
ptr_dummy1_field(struct example * s)65 ptr_dummy1_field (struct example *s)
66 {
67   return s->dummy1;
68 }
69 
70 char
ptr_dummy2_field(struct example * s)71 ptr_dummy2_field (struct example *s)
72 {
73   return s->dummy2;
74 }
75 
76 
77 int
main()78 main ()
79 {
80   if (d32_field (nums) != 3.0df) FAILURE
81   if (d64_field (nums) != 2.0dd) FAILURE
82   if (d128_field (nums) != 1.0dl) FAILURE
83   if (dummy1_field (nums) != 'a') FAILURE
84   if (dummy2_field (nums) != 'b') FAILURE
85 
86   if (ptr_d32_field (&nums) != 3.0df) FAILURE
87   if (ptr_d64_field (&nums) != 2.0dd) FAILURE
88   if (ptr_d128_field (&nums) != 1.0dl) FAILURE
89   if (ptr_dummy1_field (&nums) != 'a') FAILURE
90   if (ptr_dummy2_field (&nums) != 'b') FAILURE
91 
92   FINISH
93 }
94