struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-strct-stdarg-1.c
blobfa59c737abd293728e0b781a4d5892c08e07192b
1 /*
2 strct-stdarg-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #include <stdarg.h>
9 struct tiny
11 char c;
12 char d;
13 char e;
14 char f;
15 char g;
18 void
19 f (int n, ...)
21 struct tiny x;
22 int i;
24 va_list ap;
25 va_start (ap,n);
26 for (i = 0; i < n; i++)
28 x = va_arg (ap,struct tiny);
29 ASSERT(x.c == i + 10);
30 ASSERT(x.d == i + 20);
31 ASSERT(x.e == i + 30);
32 ASSERT(x.f == i + 40);
33 ASSERT(x.g == i + 50);
36 long x = va_arg (ap, long);
37 ASSERT(x == 123);
39 va_end (ap);
42 void
43 testTortureExecute (void)
45 struct tiny x[3];
46 x[0].c = 10;
47 x[1].c = 11;
48 x[2].c = 12;
49 x[0].d = 20;
50 x[1].d = 21;
51 x[2].d = 22;
52 x[0].e = 30;
53 x[1].e = 31;
54 x[2].e = 32;
55 x[0].f = 40;
56 x[1].f = 41;
57 x[2].f = 42;
58 x[0].g = 50;
59 x[1].g = 51;
60 x[2].g = 52;
61 #if 0 // TODO: Enable when bug #3365 (passign array element as struct param) is fixed
62 f (3, x[0], x[1], x[2], (long) 123);
63 #endif
64 return;