OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [va-arg-2.c] - Blame information for rev 816

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
/* The purpose of this test is to catch edge cases when arguments are passed
2
   in regs and on the stack.  We test 16 cases, trying to catch multiple
3
   targets (some use 3 regs for argument passing, some use 12, etc.).
4
   We test both the arguments and the `lastarg' (the argument to va_start).  */
5
 
6
#include <stdarg.h>
7
 
8
extern __SIZE_TYPE__ strlen ();
9
 
10
int
11
to_hex (unsigned int a)
12
{
13
  static char hex[] = "0123456789abcdef";
14
 
15
  if (a > 15)
16
    abort ();
17
  return hex[a];
18
}
19
 
20
void
21
f0 (char* format, ...)
22
{
23
  va_list ap;
24
 
25
  va_start (ap, format);
26
  if (strlen (format) != 16 - 0)
27
    abort ();
28
  while (*format)
29
    if (*format++ != to_hex (va_arg (ap, int)))
30
      abort ();
31
  va_end(ap);
32
}
33
 
34
void
35
f1 (int a1, char* format, ...)
36
{
37
  va_list ap;
38
 
39
  va_start(ap, format);
40
  if (strlen (format) != 16 - 1)
41
    abort ();
42
  while (*format)
43
    if (*format++ != to_hex (va_arg (ap, int)))
44
      abort ();
45
  va_end(ap);
46
}
47
 
48
void
49
f2 (int a1, int a2, char* format, ...)
50
{
51
  va_list ap;
52
 
53
  va_start(ap, format);
54
  if (strlen (format) != 16 - 2)
55
    abort ();
56
  while (*format)
57
    if (*format++ != to_hex (va_arg (ap, int)))
58
      abort ();
59
  va_end(ap);
60
}
61
 
62
void
63
f3 (int a1, int a2, int a3, char* format, ...)
64
{
65
  va_list ap;
66
 
67
  va_start(ap, format);
68
  if (strlen (format) != 16 - 3)
69
    abort ();
70
  while (*format)
71
    if (*format++ != to_hex (va_arg (ap, int)))
72
      abort ();
73
  va_end(ap);
74
}
75
 
76
void
77
f4 (int a1, int a2, int a3, int a4, char* format, ...)
78
{
79
  va_list ap;
80
 
81
  va_start(ap, format);
82
  if (strlen (format) != 16 - 4)
83
    abort ();
84
  while (*format)
85
    if (*format++ != to_hex (va_arg (ap, int)))
86
      abort ();
87
  va_end(ap);
88
}
89
 
90
void
91
f5 (int a1, int a2, int a3, int a4, int a5,
92
    char* format, ...)
93
{
94
  va_list ap;
95
 
96
  va_start(ap, format);
97
  if (strlen (format) != 16 - 5)
98
    abort ();
99
  while (*format)
100
    if (*format++ != to_hex (va_arg (ap, int)))
101
      abort ();
102
  va_end(ap);
103
}
104
 
105
void
106
f6 (int a1, int a2, int a3, int a4, int a5,
107
    int a6,
108
    char* format, ...)
109
{
110
  va_list ap;
111
 
112
  va_start(ap, format);
113
  if (strlen (format) != 16 - 6)
114
    abort ();
115
  while (*format)
116
    if (*format++ != to_hex (va_arg (ap, int)))
117
      abort ();
118
  va_end(ap);
119
}
120
 
121
void
122
f7 (int a1, int a2, int a3, int a4, int a5,
123
    int a6, int a7,
124
    char* format, ...)
125
{
126
  va_list ap;
127
 
128
  va_start(ap, format);
129
  if (strlen (format) != 16 - 7)
130
    abort ();
131
  while (*format)
132
    if (*format++ != to_hex (va_arg (ap, int)))
133
      abort ();
134
  va_end(ap);
135
}
136
 
137
void
138
f8 (int a1, int a2, int a3, int a4, int a5,
139
    int a6, int a7, int a8,
140
    char* format, ...)
141
{
142
  va_list ap;
143
 
144
  va_start(ap, format);
145
  if (strlen (format) != 16 - 8)
146
    abort ();
147
  while (*format)
148
    if (*format++ != to_hex (va_arg (ap, int)))
149
      abort ();
150
  va_end(ap);
151
}
152
 
153
void
154
f9 (int a1, int a2, int a3, int a4, int a5,
155
     int a6, int a7, int a8, int a9,
156
     char* format, ...)
157
{
158
  va_list ap;
159
 
160
  va_start(ap, format);
161
  if (strlen (format) != 16 - 9)
162
    abort ();
163
  while (*format)
164
    if (*format++ != to_hex (va_arg (ap, int)))
165
      abort ();
166
  va_end(ap);
167
}
168
 
169
void
170
f10 (int a1, int a2, int a3, int a4, int a5,
171
     int a6, int a7, int a8, int a9, int a10,
172
     char* format, ...)
173
{
174
  va_list ap;
175
 
176
  va_start(ap, format);
177
  if (strlen (format) != 16 - 10)
178
    abort ();
179
  while (*format)
180
    if (*format++ != to_hex (va_arg (ap, int)))
181
      abort ();
182
  va_end(ap);
183
}
184
 
185
void
186
f11 (int a1, int a2, int a3, int a4, int a5,
187
     int a6, int a7, int a8, int a9, int a10,
188
     int a11,
189
     char* format, ...)
190
{
191
  va_list ap;
192
 
193
  va_start(ap, format);
194
  if (strlen (format) != 16 - 11)
195
    abort ();
196
  while (*format)
197
    if (*format++ != to_hex (va_arg (ap, int)))
198
      abort ();
199
  va_end(ap);
200
}
201
 
202
void
203
f12 (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,
206
     char* format, ...)
207
{
208
  va_list ap;
209
 
210
  va_start(ap, format);
211
  if (strlen (format) != 16 - 12)
212
    abort ();
213
  while (*format)
214
    if (*format++ != to_hex (va_arg (ap, int)))
215
      abort ();
216
  va_end(ap);
217
}
218
 
219
void
220
f13 (int a1, int a2, int a3, int a4, int a5,
221
     int a6, int a7, int a8, int a9, int a10,
222
     int a11, int a12, int a13,
223
     char* format, ...)
224
{
225
  va_list ap;
226
 
227
  va_start(ap, format);
228
  if (strlen (format) != 16 - 13)
229
    abort ();
230
  while (*format)
231
    if (*format++ != to_hex (va_arg (ap, int)))
232
      abort ();
233
  va_end(ap);
234
}
235
 
236
void
237
f14 (int a1, int a2, int a3, int a4, int a5,
238
     int a6, int a7, int a8, int a9, int a10,
239
     int a11, int a12, int a13, int a14,
240
     char* format, ...)
241
{
242
  va_list ap;
243
 
244
  va_start(ap, format);
245
  if (strlen (format) != 16 - 14)
246
    abort ();
247
  while (*format)
248
    if (*format++ != to_hex (va_arg (ap, int)))
249
      abort ();
250
  va_end(ap);
251
}
252
 
253
void
254
f15 (int a1, int a2, int a3, int a4, int a5,
255
     int a6, int a7, int a8, int a9, int a10,
256
     int a11, int a12, int a13, int a14, int a15,
257
     char* format, ...)
258
{
259
  va_list ap;
260
 
261
  va_start(ap, format);
262
  if (strlen (format) != 16 - 15)
263
    abort ();
264
  while (*format)
265
    if (*format++ != to_hex (va_arg (ap, int)))
266
      abort ();
267
  va_end(ap);
268
}
269
 
270
main ()
271
{
272
  char *f = "0123456789abcdef";
273
 
274
  f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
275
  f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
276
  f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
277
  f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
278
  f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
279
  f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
280
  f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
281
  f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);
282
  f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);
283
  f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);
284
  f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);
285
  f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);
286
  f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);
287
  f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);
288
  f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);
289
  f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);
290
 
291
  exit (0);
292
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.