9 /* (INT_MAX / 2) + 2 */
15 #define STRINGIFY(S) #S
16 #define MAKE_STR(S) STRINGIFY(S)
18 #define SN MAKE_STR(N)
19 #define SN2 MAKE_STR(N2)
20 #define SN3 MAKE_STR(N3)
27 FILE *fp
= fopen ("/dev/null", "w");
30 puts ("cannot open /dev/null");
34 /* GCC 9 warns about output of more than INT_MAX characters; this is
35 deliberately tested here. */
36 DIAG_PUSH_NEEDS_COMMENT
;
37 #if __GNUC_PREREQ (7, 0)
38 DIAG_IGNORE_NEEDS_COMMENT (9, "-Wformat-overflow=");
40 ret
= fprintf (fp
, "%" SN
"d", 1);
41 DIAG_POP_NEEDS_COMMENT
;
42 printf ("ret = %d\n", ret
);
43 if (ret
!= -1 || errno
!= EOVERFLOW
)
46 /* GCC 9 warns about output of more than INT_MAX characters; this is
47 deliberately tested here. */
48 DIAG_PUSH_NEEDS_COMMENT
;
49 #if __GNUC_PREREQ (7, 0)
50 DIAG_IGNORE_NEEDS_COMMENT (9, "-Wformat-overflow=");
52 ret
= fprintf (fp
, "%." SN
"d", 1);
53 DIAG_POP_NEEDS_COMMENT
;
54 printf ("ret = %d\n", ret
);
55 if (ret
!= -1 || errno
!= EOVERFLOW
)
58 ret
= fprintf (fp
, "%." SN3
"d", 1);
59 printf ("ret = %d\n", ret
);
63 /* GCC 9 warns about output of more than INT_MAX characters; this is
64 deliberately tested here. */
65 DIAG_PUSH_NEEDS_COMMENT
;
66 #if __GNUC_PREREQ (7, 0)
67 DIAG_IGNORE_NEEDS_COMMENT (9, "-Wformat-overflow=");
69 ret
= fprintf (fp
, "%" SN2
"d%" SN2
"d", 1, 1);
70 DIAG_POP_NEEDS_COMMENT
;
71 printf ("ret = %d\n", ret
);
73 return ret
!= -1 || errno
!= EOVERFLOW
;
77 #define TEST_FUNCTION do_test ()
78 #include "../test-skeleton.c"