Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-va-arg-9.c
blob0695cd3fda923465c2a95023336228b248feaed8
1 /*
2 va-arg-9.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma disable_warning 85
9 #pragma disable_warning 196
10 #endif
12 #include <stddef.h>
14 /* This is a modfied version of va-arg-2.c to test passing a va_list as
15 a parameter to another function. */
17 #include <stdarg.h>
19 extern size_t strlen (const char *);
21 int
22 to_hex (unsigned int a)
24 static char hex[] = "0123456789abcdef";
26 if (a > 15)
27 ASSERT (0);
28 return hex[a];
31 void
32 fap (int i, char* format, va_list ap)
34 if (strlen (format) != 16 - i)
35 ASSERT (0);
36 while (*format)
37 if (*format++ != to_hex (va_arg (ap, int)))
38 ASSERT (0);
41 void
42 f0 (char* format, ...)
44 va_list ap;
46 va_start (ap, format);
47 fap(0, format, ap);
48 va_end(ap);
51 void
52 f1 (int a1, char* format, ...)
54 va_list ap;
56 va_start(ap, format);
57 fap(1, format, ap);
58 va_end(ap);
61 #if !defined(__SDCC_pdk14) // Lack of memory
62 void
63 f2 (int a1, int a2, char* format, ...)
65 va_list ap;
67 va_start(ap, format);
68 fap(2, format, ap);
69 va_end(ap);
72 void
73 f3 (int a1, int a2, int a3, char* format, ...)
75 va_list ap;
77 va_start(ap, format);
78 fap(3, format, ap);
79 va_end(ap);
82 void
83 f4 (int a1, int a2, int a3, int a4, char* format, ...)
85 va_list ap;
87 va_start(ap, format);
88 fap(4, format, ap);
89 va_end(ap);
92 void
93 f5 (int a1, int a2, int a3, int a4, int a5,
94 char* format, ...)
96 va_list ap;
98 va_start(ap, format);
99 fap(5, format, ap);
100 va_end(ap);
103 void
104 f6 (int a1, int a2, int a3, int a4, int a5,
105 int a6,
106 char* format, ...)
108 va_list ap;
110 va_start(ap, format);
111 fap(6, format, ap);
112 va_end(ap);
115 void
116 f7 (int a1, int a2, int a3, int a4, int a5,
117 int a6, int a7,
118 char* format, ...)
120 va_list ap;
122 va_start(ap, format);
123 fap(7, format, ap);
124 va_end(ap);
127 void
128 f8 (int a1, int a2, int a3, int a4, int a5,
129 int a6, int a7, int a8,
130 char* format, ...)
132 va_list ap;
134 va_start(ap, format);
135 fap(8, format, ap);
136 va_end(ap);
139 void
140 f9 (int a1, int a2, int a3, int a4, int a5,
141 int a6, int a7, int a8, int a9,
142 char* format, ...)
144 va_list ap;
146 va_start(ap, format);
147 fap(9, format, ap);
148 va_end(ap);
151 void
152 f10 (int a1, int a2, int a3, int a4, int a5,
153 int a6, int a7, int a8, int a9, int a10,
154 char* format, ...)
156 va_list ap;
158 va_start(ap, format);
159 fap(10, format, ap);
160 va_end(ap);
163 void
164 f11 (int a1, int a2, int a3, int a4, int a5,
165 int a6, int a7, int a8, int a9, int a10,
166 int a11,
167 char* format, ...)
169 va_list ap;
171 va_start(ap, format);
172 fap(11, format, ap);
173 va_end(ap);
176 void
177 f12 (int a1, int a2, int a3, int a4, int a5,
178 int a6, int a7, int a8, int a9, int a10,
179 int a11, int a12,
180 char* format, ...)
182 va_list ap;
184 va_start(ap, format);
185 fap(12, format, ap);
186 va_end(ap);
189 void
190 f13 (int a1, int a2, int a3, int a4, int a5,
191 int a6, int a7, int a8, int a9, int a10,
192 int a11, int a12, int a13,
193 char* format, ...)
195 va_list ap;
197 va_start(ap, format);
198 fap(13, format, ap);
199 va_end(ap);
202 void
203 f14 (int a1, int a2, int a3, int a4, int a5,
204 int a6, int a7, int a8, int a9, int a10,
205 int a11, int a12, int a13, int a14,
206 char* format, ...)
208 va_list ap;
210 va_start(ap, format);
211 fap(14, format, ap);
212 va_end(ap);
215 void
216 f15 (int a1, int a2, int a3, int a4, int a5,
217 int a6, int a7, int a8, int a9, int a10,
218 int a11, int a12, int a13, int a14, int a15,
219 char* format, ...)
221 va_list ap;
223 va_start(ap, format);
224 fap(15, format, ap);
225 va_end(ap);
227 #endif
229 void
230 testTortureExecute (void)
232 #if !defined(__SDCC_pdk14) // Lack of memory
233 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
234 char *f = "0123456789abcdef";
236 f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
237 f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
238 f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
239 f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
240 f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
241 f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
242 f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
243 f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);
244 f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);
245 f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);
246 f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);
247 f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);
248 f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);
249 f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);
250 f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);
251 f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);
252 #endif
253 #endif
254 return;