summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vla-14.c
blob: 3dbb11ed1a717d2b1454a3e2dfb6ea7b0789a7d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* Test for VLA size evaluation in va_arg.  */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */

#include <stdarg.h>

extern void exit (int);
extern void abort (void);

int a[10];
int i = 9;

void
f (int n, ...)
{
  va_list ap;
  void *p;
  va_start (ap, n);
  p = va_arg (ap, typeof (int (*)[++i]));
  if (p != a)
    abort ();
  if (i != n)
    abort ();
  va_end (ap);
}

int
main (void)
{
  f (10, &a);
  exit (0);
}