OSDN Git Service

PR testsuite/33082
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / dfp / func-array.c
1 /* { dg-options "-std=gnu99" } */
2
3 /* C99 6.5.2.2 Function calls.
4    Test passing array elements involving decimal floating point types. */
5
6 extern void abort (void);
7 static int failcnt;
8
9 /* Support compiling the test to report individual failures; default is
10    to abort as soon as a check fails.  */
11 #ifdef DBG
12 #include <stdio.h>
13 #define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
14 #else
15 #define FAILURE abort ();
16 #endif
17
18 /* A handful of functions that return the Nth _Decimal32 argument of
19    an incoming array.  */
20
21 _Decimal32
22 arg0_32 (_Decimal32 args[])
23 {
24   return args[0];
25 }
26
27 _Decimal32
28 arg1_32 (_Decimal32 args[])
29 {
30   return args[1];
31 }
32
33 _Decimal32
34 arg2_32 (_Decimal32 args[])
35 {
36   return args[2];
37 }
38
39 _Decimal32
40 arg3_32 (_Decimal32 args[])
41 {
42   return args[3];
43 }
44
45 _Decimal32
46 arg4_32 (_Decimal32 args[])
47 {
48   return args[4];
49 }
50
51 _Decimal32
52 arg5_32 (_Decimal32 args[])
53 {
54   return args[5];
55 }
56         
57 \f
58 /* A handful of functions that return the Nth _Decimal64 argument of
59    an incoming array.  */
60
61 _Decimal64
62 arg0_64 (_Decimal64 args[])
63 {
64   return args[0];
65 }
66
67 _Decimal64
68 arg1_64 (_Decimal64 args[])
69 {
70   return args[1];
71 }
72
73 _Decimal64
74 arg2_64 (_Decimal64 args[])
75 {
76   return args[2];
77 }
78
79 _Decimal64
80 arg3_64 (_Decimal64 args[])
81 {
82   return args[3];
83 }
84
85 _Decimal64
86 arg4_64 (_Decimal64 args[])
87 {
88   return args[4];
89 }
90
91 _Decimal64
92 arg5_64 (_Decimal64 args[])
93 {
94   return args[5];
95 }
96
97 \f
98 /* A handful of functions that return the Nth _Decimal128 argument of
99    an incoming array.  */
100
101 _Decimal128
102 arg0_128 (_Decimal128 args[])
103 {
104   return args[0];
105 }
106
107 _Decimal128
108 arg1_128 (_Decimal128 args[])
109 {
110   return args[1];
111 }
112
113 _Decimal128
114 arg2_128 (_Decimal128 args[])
115 {
116   return args[2];
117 }
118
119 _Decimal128
120 arg3_128 (_Decimal128 args[])
121 {
122   return args[3];
123 }
124
125 _Decimal128
126 arg4_128 (_Decimal128 args[])
127 {
128   return args[4];
129 }
130
131 _Decimal128
132 arg5_128 (_Decimal128 args[])
133 {
134   return args[5];
135 }
136
137 \f
138 int main()
139 {
140   _Decimal32 d32[] = { 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df };
141   _Decimal64 d64[] = { 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd };
142   _Decimal128 d128[] = { 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl };
143
144   /* _Decimal32 variants.  */
145   if (arg0_32 (d32) != 0.0df) FAILURE
146   if (arg1_32 (d32) != 1.0df) FAILURE
147   if (arg2_32 (d32) != 2.0df) FAILURE
148   if (arg3_32 (d32) != 3.0df) FAILURE
149   if (arg4_32 (d32) != 4.0df) FAILURE
150   if (arg5_32 (d32) != 5.0df) FAILURE
151
152   /* _Decimal64 variants.  */
153   if (arg0_64 (d64) != 0.0dd) FAILURE
154   if (arg1_64 (d64) != 1.0dd) FAILURE
155   if (arg2_64 (d64) != 2.0dd) FAILURE
156   if (arg3_64 (d64) != 3.0dd) FAILURE
157   if (arg4_64 (d64) != 4.0dd) FAILURE
158   if (arg5_64 (d64) != 5.0dd) FAILURE
159
160   /* _Decimal128 variants.  */
161   if (arg0_128 (d128) != 0.0dl) FAILURE
162   if (arg1_128 (d128) != 1.0dl) FAILURE
163   if (arg2_128 (d128) != 2.0dl) FAILURE
164   if (arg3_128 (d128) != 3.0dl) FAILURE
165   if (arg4_128 (d128) != 4.0dl) FAILURE
166   if (arg5_128 (d128) != 5.0dl) FAILURE
167
168   if (failcnt != 0)
169     abort ();
170
171   return 0;
172 }