PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20020412-1.c
blob58205d23d5b364036275e85cd8135c995650b3a7
1 /* PR c/3711
2 This testcase ICEd on IA-32 at -O0 and was miscompiled otherwise,
3 because std_expand_builtin_va_arg didn't handle variable size types. */
4 /* { dg-require-effective-target alloca } */
6 #include <stdarg.h>
8 extern void abort (void);
9 extern void exit (int);
11 void bar (int c)
13 static int d = '0';
15 if (c != d++)
16 abort ();
17 if (c < '0' || c > '9')
18 abort ();
21 void foo (int size, ...)
23 struct
25 char x[size];
26 } d;
27 va_list ap;
28 int i;
30 va_start (ap, size);
31 d = va_arg (ap, typeof (d));
32 for (i = 0; i < size; i++)
33 bar (d.x[i]);
34 d = va_arg (ap, typeof (d));
35 for (i = 0; i < size; i++)
36 bar (d.x[i]);
37 va_end (ap);
40 int main (void)
42 int z = 5;
43 struct { char a[z]; } x, y;
45 x.a[0] = '0';
46 x.a[1] = '1';
47 x.a[2] = '2';
48 x.a[3] = '3';
49 x.a[4] = '4';
50 y.a[0] = '5';
51 y.a[1] = '6';
52 y.a[2] = '7';
53 y.a[3] = '8';
54 y.a[4] = '9';
55 foo (z, x, y);
56 exit (0);