PR middle-end/30262
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20041214-1.c
blob89df2be8e3a2f57311f4d5d1040a7eb24d8b11a2
1 typedef long unsigned int size_t;
2 extern void abort (void);
3 extern char *strcpy (char *, const char *);
4 extern int strcmp (const char *, const char *);
5 typedef __builtin_va_list va_list;
6 static const char null[] = "(null)";
7 int g (char *s, const char *format, va_list ap)
9 const char *f;
10 const char *string;
11 char spec;
12 static const void *step0_jumps[] = {
13 &&do_precision,
14 &&do_form_integer,
15 &&do_form_string,
17 f = format;
18 if (*f == '\0')
19 goto all_done;
22 spec = (*++f);
23 goto *(step0_jumps[2]);
25 /* begin switch table. */
26 do_precision:
27 ++f;
28 __builtin_va_arg (ap, int);
29 spec = *f;
30 goto *(step0_jumps[2]);
32 do_form_integer:
33 __builtin_va_arg (ap, unsigned long int);
34 goto end;
36 do_form_string:
37 string = __builtin_va_arg (ap, const char *);
38 strcpy (s, string);
40 /* End of switch table. */
41 end:
42 ++f;
44 while (*f != '\0');
46 all_done:
47 return 0;
50 void
51 f (char *s, const char *f, ...)
53 va_list ap;
54 __builtin_va_start (ap, f);
55 g (s, f, ap);
56 __builtin_va_end (ap);
59 int
60 main (void)
62 char buf[10];
63 f (buf, "%s", "asdf", 0);
64 if (strcmp (buf, "asdf"))
65 abort ();
66 return 0;