PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / va-arg-9.c
blobf0a92dcdd7287508b665c80a91d440146080f201
1 /* This is a modfied version of va-arg-2.c to test passing a va_list as
2 a parameter to another function. */
4 #include <stdarg.h>
6 extern __SIZE_TYPE__ strlen (const char *);
8 int
9 to_hex (unsigned int a)
11 static char hex[] = "0123456789abcdef";
13 if (a > 15)
14 abort ();
15 return hex[a];
18 void
19 fap (int i, char* format, va_list ap)
21 if (strlen (format) != 16 - i)
22 abort ();
23 while (*format)
24 if (*format++ != to_hex (va_arg (ap, int)))
25 abort ();
28 void
29 f0 (char* format, ...)
31 va_list ap;
33 va_start (ap, format);
34 fap(0, format, ap);
35 va_end(ap);
38 void
39 f1 (int a1, char* format, ...)
41 va_list ap;
43 va_start(ap, format);
44 fap(1, format, ap);
45 va_end(ap);
48 void
49 f2 (int a1, int a2, char* format, ...)
51 va_list ap;
53 va_start(ap, format);
54 fap(2, format, ap);
55 va_end(ap);
58 void
59 f3 (int a1, int a2, int a3, char* format, ...)
61 va_list ap;
63 va_start(ap, format);
64 fap(3, format, ap);
65 va_end(ap);
68 void
69 f4 (int a1, int a2, int a3, int a4, char* format, ...)
71 va_list ap;
73 va_start(ap, format);
74 fap(4, format, ap);
75 va_end(ap);
78 void
79 f5 (int a1, int a2, int a3, int a4, int a5,
80 char* format, ...)
82 va_list ap;
84 va_start(ap, format);
85 fap(5, format, ap);
86 va_end(ap);
89 void
90 f6 (int a1, int a2, int a3, int a4, int a5,
91 int a6,
92 char* format, ...)
94 va_list ap;
96 va_start(ap, format);
97 fap(6, format, ap);
98 va_end(ap);
101 void
102 f7 (int a1, int a2, int a3, int a4, int a5,
103 int a6, int a7,
104 char* format, ...)
106 va_list ap;
108 va_start(ap, format);
109 fap(7, format, ap);
110 va_end(ap);
113 void
114 f8 (int a1, int a2, int a3, int a4, int a5,
115 int a6, int a7, int a8,
116 char* format, ...)
118 va_list ap;
120 va_start(ap, format);
121 fap(8, format, ap);
122 va_end(ap);
125 void
126 f9 (int a1, int a2, int a3, int a4, int a5,
127 int a6, int a7, int a8, int a9,
128 char* format, ...)
130 va_list ap;
132 va_start(ap, format);
133 fap(9, format, ap);
134 va_end(ap);
137 void
138 f10 (int a1, int a2, int a3, int a4, int a5,
139 int a6, int a7, int a8, int a9, int a10,
140 char* format, ...)
142 va_list ap;
144 va_start(ap, format);
145 fap(10, format, ap);
146 va_end(ap);
149 void
150 f11 (int a1, int a2, int a3, int a4, int a5,
151 int a6, int a7, int a8, int a9, int a10,
152 int a11,
153 char* format, ...)
155 va_list ap;
157 va_start(ap, format);
158 fap(11, format, ap);
159 va_end(ap);
162 void
163 f12 (int a1, int a2, int a3, int a4, int a5,
164 int a6, int a7, int a8, int a9, int a10,
165 int a11, int a12,
166 char* format, ...)
168 va_list ap;
170 va_start(ap, format);
171 fap(12, format, ap);
172 va_end(ap);
175 void
176 f13 (int a1, int a2, int a3, int a4, int a5,
177 int a6, int a7, int a8, int a9, int a10,
178 int a11, int a12, int a13,
179 char* format, ...)
181 va_list ap;
183 va_start(ap, format);
184 fap(13, format, ap);
185 va_end(ap);
188 void
189 f14 (int a1, int a2, int a3, int a4, int a5,
190 int a6, int a7, int a8, int a9, int a10,
191 int a11, int a12, int a13, int a14,
192 char* format, ...)
194 va_list ap;
196 va_start(ap, format);
197 fap(14, format, ap);
198 va_end(ap);
201 void
202 f15 (int a1, int a2, int a3, int a4, int a5,
203 int a6, int a7, int a8, int a9, int a10,
204 int a11, int a12, int a13, int a14, int a15,
205 char* format, ...)
207 va_list ap;
209 va_start(ap, format);
210 fap(15, format, ap);
211 va_end(ap);
214 main ()
216 char *f = "0123456789abcdef";
218 f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
219 f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
220 f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
221 f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
222 f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
223 f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
224 f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
225 f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);
226 f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);
227 f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);
228 f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);
229 f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);
230 f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);
231 f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);
232 f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);
233 f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);
235 exit (0);