Reset branch to trunk.
[official-gcc.git] / trunk / gcc / testsuite / gcc.c-torture / execute / vprintf-1.c
blob9f1b8bf67aa3535aaf5f542f980de9139fa0a369
1 #ifndef test
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <stdarg.h>
6 void
7 inner (int x, ...)
9 va_list ap, ap2;
10 va_start (ap, x);
11 va_start (ap2, x);
13 switch (x)
15 #define test(n, ret, fmt, args) \
16 case n: \
17 vprintf (fmt, ap); \
18 if (vprintf (fmt, ap2) != ret) \
19 abort (); \
20 break;
21 #include "vprintf-1.c"
22 #undef test
23 default:
24 abort ();
27 va_end (ap);
28 va_end (ap2);
31 int
32 main (void)
34 #define test(n, ret, fmt, args) \
35 inner args;
36 #include "vprintf-1.c"
37 #undef test
38 return 0;
41 #else
42 test (0, 5, "hello", (0));
43 test (1, 6, "hello\n", (1));
44 test (2, 1, "a", (2));
45 test (3, 0, "", (3));
46 test (4, 5, "%s", (4, "hello"));
47 test (5, 6, "%s", (5, "hello\n"));
48 test (6, 1, "%s", (6, "a"));
49 test (7, 0, "%s", (7, ""));
50 test (8, 1, "%c", (8, 'x'));
51 test (9, 7, "%s\n", (9, "hello\n"));
52 test (10, 2, "%d\n", (10, 0));
53 #endif