1 /* { dg-skip-if "requires io" { freestanding } }  */
2 
3 #ifndef test
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <stdarg.h>
7 
8 void
inner(int x,...)9 inner (int x, ...)
10 {
11   va_list ap, ap2;
12   va_start (ap, x);
13   va_start (ap2, x);
14 
15   switch (x)
16     {
17 #define test(n, ret, fmt, args) \
18     case n:					\
19       vfprintf (stdout, fmt, ap);		\
20       if (vfprintf (stdout, fmt, ap2) != ret)	\
21 	abort ();				\
22       break;
23 #include "vfprintf-1.c"
24 #undef test
25     default:
26       abort ();
27     }
28 
29   va_end (ap);
30   va_end (ap2);
31 }
32 
33 int
main(void)34 main (void)
35 {
36 #define test(n, ret, fmt, args) \
37   inner args;
38 #include "vfprintf-1.c"
39 #undef test
40   return 0;
41 }
42 
43 #else
44   test (0, 5, "hello", (0));
45   test (1, 6, "hello\n", (1));
46   test (2, 1, "a", (2));
47   test (3, 0, "", (3));
48   test (4, 5, "%s", (4, "hello"));
49   test (5, 6, "%s", (5, "hello\n"));
50   test (6, 1, "%s", (6, "a"));
51   test (7, 0, "%s", (7, ""));
52   test (8, 1, "%c", (8, 'x'));
53   test (9, 7, "%s\n", (9, "hello\n"));
54   test (10, 2, "%d\n", (10, 0));
55 #endif
56