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
5#include <stdarg.h>
6
7extern void abort (void);
8extern void exit (int);
9
10void bar (int c)
11{
12  static int d = '0';
13
14  if (c != d++)
15    abort ();
16  if (c < '0' || c > '9')
17    abort ();
18}
19
20void foo (int size, ...)
21{
22  struct
23  {
24    char x[size];
25  } d;
26  va_list ap;
27  int i;
28
29  va_start (ap, size);
30  d = va_arg (ap, typeof (d));
31  for (i = 0; i < size; i++)
32    bar (d.x[i]);
33  d = va_arg (ap, typeof (d));
34  for (i = 0; i < size; i++)
35    bar (d.x[i]);
36  va_end (ap);
37}
38
39int main (void)
40{
41  int z = 5;
42  struct { char a[z]; } x, y;
43
44  x.a[0] = '0';
45  x.a[1] = '1';
46  x.a[2] = '2';
47  x.a[3] = '3';
48  x.a[4] = '4';
49  y.a[0] = '5';
50  y.a[1] = '6';
51  y.a[2] = '7';
52  y.a[3] = '8';
53  y.a[4] = '9';
54  foo (z, x, y);
55  exit (0);
56}
57