PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / vfprintf-1.c
blob0ac41dee3d6fd0cb019f77c6339a8656fda78ed1
1 /* { dg-skip-if "requires io" { freestanding } } */
3 #ifndef test
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <stdarg.h>
8 void
9 inner (int x, ...)
11 va_list ap, ap2;
12 va_start (ap, x);
13 va_start (ap2, x);
15 switch (x)
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 ();
29 va_end (ap);
30 va_end (ap2);
33 int
34 main (void)
36 #define test(n, ret, fmt, args) \
37 inner args;
38 #include "vfprintf-1.c"
39 #undef test
40 return 0;
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