summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/va-arg-13.c
blob: 65caf2b9af1ac5c9777f17a17f64fbaafb6d13d3 (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
34
35
36
37
38
/* derived from mozilla source code */

#include <stdarg.h>

typedef struct {
  void *stream;
  va_list ap;
  int nChar;  
} ScanfState;

void dummy (va_list vap)
{
  if (va_arg (vap, int) != 1234) abort();
  return;
}

void test (int fmt, ...)
{
  ScanfState state, *statep;

  statep = &state;

  va_start (statep->ap, fmt);
  dummy (statep->ap);
  va_end (statep->ap);
  
  va_start (state.ap, fmt);
  dummy (state.ap);
  va_end (state.ap);
  
  return;
}

int main (void)
{
  test (456, 1234);
  exit (0);
}