1 /* { dg-skip-if "requires io" { freestanding } } */
7 volatile int should_optimize
;
10 __attribute__((noinline
))
11 __fprintf_chk (FILE *f
, int flag
, const char *fmt
, ...)
21 ret
= vfprintf (f
, fmt
, ap
);
29 #define test(ret, opt, args...) \
30 should_optimize = opt; \
31 __fprintf_chk (stdout, 1, args); \
32 if (!should_optimize) \
34 should_optimize = 0; \
35 if (__fprintf_chk (stdout, 1, args) != ret) \
37 if (!should_optimize) \
40 test (6, 1, "hello\n");
43 test (5, 1, "%s", "hello");
44 test (6, 1, "%s", "hello\n");
45 test (1, 1, "%s", "a");
46 test (0, 1, "%s", "");
47 test (1, 1, "%c", 'x');
48 test (7, 0, "%s\n", "hello\n");
49 test (2, 0, "%d\n", 0);