Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.c-torture / execute / vfprintf-chk-1.c
blobf8f964c7e9af28828eca817159e666c1fae0fa22
1 #ifndef test
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <stdarg.h>
6 volatile int should_optimize;
8 int
9 __attribute__((noinline))
10 __vfprintf_chk (FILE *f, int flag, const char *fmt, va_list ap)
12 #ifdef __OPTIMIZE__
13 if (should_optimize)
14 abort ();
15 #endif
16 should_optimize = 1;
17 return vfprintf (f, fmt, ap);
20 void
21 inner (int x, ...)
23 va_list ap, ap2;
24 va_start (ap, x);
25 va_start (ap2, x);
27 switch (x)
29 #define test(n, ret, opt, fmt, args) \
30 case n: \
31 should_optimize = opt; \
32 __vfprintf_chk (stdout, 1, fmt, ap); \
33 if (! should_optimize) \
34 abort (); \
35 should_optimize = 0; \
36 if (__vfprintf_chk (stdout, 1, fmt, ap2) != ret) \
37 abort (); \
38 if (! should_optimize) \
39 abort (); \
40 break;
41 #include "vfprintf-chk-1.c"
42 #undef test
43 default:
44 abort ();
47 va_end (ap);
48 va_end (ap2);
51 int
52 main (void)
54 #define test(n, ret, opt, fmt, args) \
55 inner args;
56 #include "vfprintf-chk-1.c"
57 #undef test
58 return 0;
61 #else
62 test (0, 5, 1, "hello", (0));
63 test (1, 6, 1, "hello\n", (1));
64 test (2, 1, 1, "a", (2));
65 test (3, 0, 1, "", (3));
66 test (4, 5, 0, "%s", (4, "hello"));
67 test (5, 6, 0, "%s", (5, "hello\n"));
68 test (6, 1, 0, "%s", (6, "a"));
69 test (7, 0, 0, "%s", (7, ""));
70 test (8, 1, 0, "%c", (8, 'x'));
71 test (9, 7, 0, "%s\n", (9, "hello\n"));
72 test (10, 2, 0, "%d\n", (10, 0));
73 #endif