2 va-arg-2.c from the execute part of the gcc torture tests.
8 #pragma disable_warning 85
9 #pragma disable_warning 196
14 /* The purpose of this test is to catch edge cases when arguments are passed
15 in regs and on the stack. We test 16 cases, trying to catch multiple
16 targets (some use 3 regs for argument passing, some use 12, etc.).
17 We test both the arguments and the `lastarg' (the argument to va_start). */
22 to_hex (unsigned int a
)
24 static char hex
[] = "0123456789abcdef";
31 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
33 f0 (char* format
, ...)
37 va_start (ap
, format
);
38 if (strlen (format
) != 16 - 0)
41 if (*format
++ != to_hex (va_arg (ap
, int)))
47 f1 (int a1
, char* format
, ...)
52 if (strlen (format
) != 16 - 1)
55 if (*format
++ != to_hex (va_arg (ap
, int)))
61 f2 (int a1
, int a2
, char* format
, ...)
66 if (strlen (format
) != 16 - 2)
69 if (*format
++ != to_hex (va_arg (ap
, int)))
75 f3 (int a1
, int a2
, int a3
, char* format
, ...)
80 if (strlen (format
) != 16 - 3)
83 if (*format
++ != to_hex (va_arg (ap
, int)))
89 f4 (int a1
, int a2
, int a3
, int a4
, char* format
, ...)
94 if (strlen (format
) != 16 - 4)
97 if (*format
++ != to_hex (va_arg (ap
, int)))
103 f5 (int a1
, int a2
, int a3
, int a4
, int a5
,
108 va_start(ap
, format
);
109 if (strlen (format
) != 16 - 5)
112 if (*format
++ != to_hex (va_arg (ap
, int)))
118 f6 (int a1
, int a2
, int a3
, int a4
, int a5
,
124 va_start(ap
, format
);
125 if (strlen (format
) != 16 - 6)
128 if (*format
++ != to_hex (va_arg (ap
, int)))
134 f7 (int a1
, int a2
, int a3
, int a4
, int a5
,
140 va_start(ap
, format
);
141 if (strlen (format
) != 16 - 7)
144 if (*format
++ != to_hex (va_arg (ap
, int)))
150 f8 (int a1
, int a2
, int a3
, int a4
, int a5
,
151 int a6
, int a7
, int a8
,
156 va_start(ap
, format
);
157 if (strlen (format
) != 16 - 8)
160 if (*format
++ != to_hex (va_arg (ap
, int)))
166 f9 (int a1
, int a2
, int a3
, int a4
, int a5
,
167 int a6
, int a7
, int a8
, int a9
,
172 va_start(ap
, format
);
173 if (strlen (format
) != 16 - 9)
176 if (*format
++ != to_hex (va_arg (ap
, int)))
182 f10 (int a1
, int a2
, int a3
, int a4
, int a5
,
183 int a6
, int a7
, int a8
, int a9
, int a10
,
188 va_start(ap
, format
);
189 if (strlen (format
) != 16 - 10)
192 if (*format
++ != to_hex (va_arg (ap
, int)))
198 f11 (int a1
, int a2
, int a3
, int a4
, int a5
,
199 int a6
, int a7
, int a8
, int a9
, int a10
,
205 va_start(ap
, format
);
206 if (strlen (format
) != 16 - 11)
209 if (*format
++ != to_hex (va_arg (ap
, int)))
215 f12 (int a1
, int a2
, int a3
, int a4
, int a5
,
216 int a6
, int a7
, int a8
, int a9
, int a10
,
222 va_start(ap
, format
);
223 if (strlen (format
) != 16 - 12)
226 if (*format
++ != to_hex (va_arg (ap
, int)))
232 f13 (int a1
, int a2
, int a3
, int a4
, int a5
,
233 int a6
, int a7
, int a8
, int a9
, int a10
,
234 int a11
, int a12
, int a13
,
239 va_start(ap
, format
);
240 if (strlen (format
) != 16 - 13)
243 if (*format
++ != to_hex (va_arg (ap
, int)))
249 f14 (int a1
, int a2
, int a3
, int a4
, int a5
,
250 int a6
, int a7
, int a8
, int a9
, int a10
,
251 int a11
, int a12
, int a13
, int a14
,
256 va_start(ap
, format
);
257 if (strlen (format
) != 16 - 14)
260 if (*format
++ != to_hex (va_arg (ap
, int)))
266 f15 (int a1
, int a2
, int a3
, int a4
, int a5
,
267 int a6
, int a7
, int a8
, int a9
, int a10
,
268 int a11
, int a12
, int a13
, int a14
, int a15
,
273 va_start(ap
, format
);
274 if (strlen (format
) != 16 - 15)
277 if (*format
++ != to_hex (va_arg (ap
, int)))
284 testTortureExecute (void)
286 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
287 char *f
= "0123456789abcdef";
289 f0 (f
+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
290 f1 (0, f
+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
291 f2 (0, 1, f
+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
292 f3 (0, 1, 2, f
+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
293 f4 (0, 1, 2, 3, f
+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
294 f5 (0, 1, 2, 3, 4, f
+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
295 f6 (0, 1, 2, 3, 4, 5, f
+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
296 f7 (0, 1, 2, 3, 4, 5, 6, f
+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);
297 f8 (0, 1, 2, 3, 4, 5, 6, 7, f
+8, 8, 9, 10, 11, 12, 13, 14, 15);
298 f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f
+9, 9, 10, 11, 12, 13, 14, 15);
299 f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f
+10, 10, 11, 12, 13, 14, 15);
300 f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f
+11, 11, 12, 13, 14, 15);
301 f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f
+12, 12, 13, 14, 15);
302 f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f
+13, 13, 14, 15);
303 f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f
+14, 14, 15);
304 f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f
+15, 15);