1 /* { dg-skip-if "requires io" { freestanding } } */
8 volatile int should_optimize
;
11 __attribute__((noinline
))
12 __vprintf_chk (int flag
, const char *fmt
, va_list ap
)
19 return vprintf (fmt
, ap
);
31 #define test(n, ret, opt, fmt, args) \
33 should_optimize = opt; \
34 __vprintf_chk (1, fmt, ap); \
35 if (! should_optimize) \
37 should_optimize = 0; \
38 if (__vprintf_chk (1, fmt, ap2) != ret) \
40 if (! should_optimize) \
43 #include "vprintf-chk-1.c"
56 #define test(n, ret, opt, fmt, args) \
58 #include "vprintf-chk-1.c"
64 test (0, 5, 0, "hello", (0));
65 test (1, 6, 1, "hello\n", (1));
66 test (2, 1, 1, "a", (2));
67 test (3, 0, 1, "", (3));
68 test (4, 5, 0, "%s", (4, "hello"));
69 test (5, 6, 0, "%s", (5, "hello\n"));
70 test (6, 1, 0, "%s", (6, "a"));
71 test (7, 0, 0, "%s", (7, ""));
72 test (8, 1, 0, "%c", (8, 'x'));
73 test (9, 7, 0, "%s\n", (9, "hello\n"));
74 test (10, 2, 0, "%d\n", (10, 0));