5 volatile int should_optimize
;
8 __attribute__((noinline
))
9 __printf_chk (int flag
, const char *fmt
, ...)
19 ret
= vprintf (fmt
, ap
);
27 #define test(ret, opt, args...) \
28 should_optimize = opt; \
29 __printf_chk (1, args); \
30 if (!should_optimize) \
32 should_optimize = 0; \
33 if (__printf_chk (1, args) != ret) \
35 if (!should_optimize) \
38 test (6, 1, "hello\n");
41 test (5, 0, "%s", "hello");
42 test (6, 1, "%s", "hello\n");
43 test (1, 1, "%s", "a");
44 test (0, 1, "%s", "");
45 test (1, 1, "%c", 'x');
46 test (7, 1, "%s\n", "hello\n");
47 test (2, 0, "%d\n", 0);