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-10.c
blob8e2b12e00ea589f5bef5afc94384dfc385cc847e
1 /*
2 va-arg-10.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #include <stddef.h>
9 #ifdef __SDCC
10 #pragma disable_warning 85
11 #pragma disable_warning 196
12 #endif
14 /* This is a modfied version of va-arg-9.c to test va_copy. */
16 #include <stdarg.h>
18 #ifndef va_copy
19 #define va_copy __va_copy
20 #endif
22 extern size_t strlen (const char *);
24 int
25 to_hex (unsigned int a)
27 static char hex[] = "0123456789abcdef";
29 if (a > 15)
30 ASSERT (0);
31 return hex[a];
34 void
35 fap (int i, char* format, va_list ap)
37 va_list apc;
38 char *formatc;
40 va_copy (apc, ap);
41 formatc = format;
43 if (strlen (format) != 16 - i)
44 ASSERT (0);
45 while (*format)
46 if (*format++ != to_hex (va_arg (ap, int)))
47 ASSERT (0);
48 while (*formatc)
49 if (*formatc++ != to_hex (va_arg (apc, int)))
50 ASSERT (0);
53 void
54 f0 (char* format, ...)
56 va_list ap;
58 va_start (ap, format);
59 fap(0, format, ap);
60 va_end(ap);
63 void
64 f1 (int a1, char* format, ...)
66 va_list ap;
68 va_start(ap, format);
69 fap(1, format, ap);
70 va_end(ap);
73 void
74 f2 (int a1, int a2, char* format, ...)
76 va_list ap;
78 va_start(ap, format);
79 fap(2, format, ap);
80 va_end(ap);
83 void
84 f3 (int a1, int a2, int a3, char* format, ...)
86 va_list ap;
88 va_start(ap, format);
89 fap(3, format, ap);
90 va_end(ap);
93 void
94 f4 (int a1, int a2, int a3, int a4, char* format, ...)
96 va_list ap;
98 va_start(ap, format);
99 fap(4, format, ap);
100 va_end(ap);
103 void
104 f5 (int a1, int a2, int a3, int a4, int a5,
105 char* format, ...)
107 va_list ap;
109 va_start(ap, format);
110 fap(5, format, ap);
111 va_end(ap);
114 void
115 f6 (int a1, int a2, int a3, int a4, int a5,
116 int a6,
117 char* format, ...)
119 va_list ap;
121 va_start(ap, format);
122 fap(6, format, ap);
123 va_end(ap);
126 void
127 f7 (int a1, int a2, int a3, int a4, int a5,
128 int a6, int a7,
129 char* format, ...)
131 va_list ap;
133 va_start(ap, format);
134 fap(7, format, ap);
135 va_end(ap);
138 void
139 f8 (int a1, int a2, int a3, int a4, int a5,
140 int a6, int a7, int a8,
141 char* format, ...)
143 va_list ap;
145 va_start(ap, format);
146 fap(8, format, ap);
147 va_end(ap);
150 void
151 f9 (int a1, int a2, int a3, int a4, int a5,
152 int a6, int a7, int a8, int a9,
153 char* format, ...)
155 va_list ap;
157 va_start(ap, format);
158 fap(9, format, ap);
159 va_end(ap);
162 void
163 f10 (int a1, int a2, int a3, int a4, int a5,
164 int a6, int a7, int a8, int a9, int a10,
165 char* format, ...)
167 va_list ap;
169 va_start(ap, format);
170 fap(10, format, ap);
171 va_end(ap);
174 void
175 f11 (int a1, int a2, int a3, int a4, int a5,
176 int a6, int a7, int a8, int a9, int a10,
177 int a11,
178 char* format, ...)
180 va_list ap;
182 va_start(ap, format);
183 fap(11, format, ap);
184 va_end(ap);
187 void
188 f12 (int a1, int a2, int a3, int a4, int a5,
189 int a6, int a7, int a8, int a9, int a10,
190 int a11, int a12,
191 char* format, ...)
193 va_list ap;
195 va_start(ap, format);
196 fap(12, format, ap);
197 va_end(ap);
200 void
201 f13 (int a1, int a2, int a3, int a4, int a5,
202 int a6, int a7, int a8, int a9, int a10,
203 int a11, int a12, int a13,
204 char* format, ...)
206 va_list ap;
208 va_start(ap, format);
209 fap(13, format, ap);
210 va_end(ap);
213 void
214 f14 (int a1, int a2, int a3, int a4, int a5,
215 int a6, int a7, int a8, int a9, int a10,
216 int a11, int a12, int a13, int a14,
217 char* format, ...)
219 va_list ap;
221 va_start(ap, format);
222 fap(14, format, ap);
223 va_end(ap);
226 void
227 f15 (int a1, int a2, int a3, int a4, int a5,
228 int a6, int a7, int a8, int a9, int a10,
229 int a11, int a12, int a13, int a14, int a15,
230 char* format, ...)
232 va_list ap;
234 va_start(ap, format);
235 fap(15, format, ap);
236 va_end(ap);
239 void
240 testTortureExecute (void)
242 #if !defined(__SDCC_pdk14) // Lack of memory
243 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
244 char *f = "0123456789abcdef";
246 f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
247 f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
248 f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
249 f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
250 f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
251 f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
252 f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
253 f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);
254 f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);
255 f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);
256 f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);
257 f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);
258 f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);
259 f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);
260 f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);
261 f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);
262 #endif
263 #endif
264 return;