summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/20041214-1.c
blob: 89df2be8e3a2f57311f4d5d1040a7eb24d8b11a2 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
typedef long unsigned int size_t;
extern void abort (void);
extern char *strcpy (char *, const char *);
extern int strcmp (const char *, const char *);
typedef __builtin_va_list va_list;
static const char null[] = "(null)";
int g (char *s, const char *format, va_list ap)
{
  const char *f;
  const char *string;
  char spec;
  static const void *step0_jumps[] = {
    &&do_precision,
    &&do_form_integer,
    &&do_form_string,
  };
  f = format;
  if (*f == '\0')
    goto all_done;
  do
    {
      spec = (*++f);
      goto *(step0_jumps[2]);
      
    /* begin switch table. */
    do_precision:
      ++f;
      __builtin_va_arg (ap, int);
      spec = *f;
      goto *(step0_jumps[2]);
      
      do_form_integer:
	__builtin_va_arg (ap, unsigned long int);
	goto end;
	
      do_form_string:
	string = __builtin_va_arg (ap, const char *);
	strcpy (s, string);
      
      /* End of switch table. */
      end:
      ++f;
    }
  while (*f != '\0');

all_done:
  return 0;
}

void
f (char *s, const char *f, ...)
{
  va_list ap;
  __builtin_va_start (ap, f);
  g (s, f, ap);
  __builtin_va_end (ap);
}

int
main (void)
{
  char buf[10];
  f (buf, "%s", "asdf", 0);
  if (strcmp (buf, "asdf"))
    abort ();
  return 0;
}