1 /* C99 6.5.2.2 Function calls.
2 Test passing varargs of the decimal float types. */
3
4 #include <stdarg.h>
5 #include "dfp-dbg.h"
6
7 static _Decimal32
vararg32(unsigned arg,...)8 vararg32 (unsigned arg, ...)
9 {
10 int i;
11 va_list ap;
12 _Decimal32 result;
13
14 va_start (ap, arg);
15 for (i = 0; i <= arg; i++)
16 result = va_arg (ap, _Decimal32);
17 va_end (ap);
18 return result;
19 }
20
21 static _Decimal64
vararg64(unsigned arg,...)22 vararg64 (unsigned arg, ...)
23 {
24 int i;
25 va_list ap;
26 _Decimal64 result;
27
28 va_start (ap, arg);
29 for (i = 0; i <= arg; i++)
30 result = va_arg (ap, _Decimal64);
31 va_end (ap);
32 return result;
33 }
34
35 static _Decimal128
vararg128(unsigned arg,...)36 vararg128 (unsigned arg, ...)
37 {
38 int i;
39 va_list ap;
40 _Decimal128 result;
41
42 va_start (ap, arg);
43 for (i = 0; i <= arg; i++)
44 result = va_arg (ap, _Decimal128);
45 va_end (ap);
46 return result;
47 }
48
49
main()50 int main()
51 {
52 /* _Decimal32 variants. */
53 if (vararg32 (0, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 0.0df)
54 FAILURE
55 if (vararg32 (1, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 1.0df)
56 FAILURE
57 if (vararg32 (2, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 2.0df)
58 FAILURE
59 if (vararg32 (3, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 3.0df)
60 FAILURE
61 if (vararg32 (4, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 4.0df)
62 FAILURE
63 if (vararg32 (5, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 5.0df)
64 FAILURE
65
66 /* _Decimal64 variants. */
67 if (vararg64 (0, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 0.0dd)
68 FAILURE
69 if (vararg64 (1, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 1.0dd)
70 FAILURE
71 if (vararg64 (2, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 2.0dd)
72 FAILURE
73 if (vararg64 (3, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 3.0dd)
74 FAILURE
75 if (vararg64 (4, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 4.0dd)
76 FAILURE
77 if (vararg64 (5, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 5.0dd)
78 FAILURE
79
80 /* _Decimal128 variants. */
81 if (vararg128 (0, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 0.0dl)
82 FAILURE
83 if (vararg128 (1, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 1.0dl)
84 FAILURE
85 if (vararg128 (2, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 2.0dl)
86 FAILURE
87 if (vararg128 (3, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 3.0dl)
88 FAILURE
89 if (vararg128 (4, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 4.0dl)
90 FAILURE
91 if (vararg128 (5, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 5.0dl)
92 FAILURE
93
94 FINISH
95 }
96