1 /* PR tree-optimization/91567 - Spurious -Wformat-overflow warnings building
4 { dg-options "-O2 -Wall -ftrack-macro-expansion=0" }
5 { dg-require-effective-target alloca } */
7 typedef __SIZE_TYPE__
size_t;
9 extern int sprintf (char*, const char*, ...);
10 extern size_t strlen (const char*);
14 void g (char *s1
, char *s2
)
17 size_t n
= __builtin_strlen (s1
), d
= __builtin_strlen (s2
);
18 if (n
+ d
+ 1 >= 1025)
21 /* Ranger can find ranges here:
22 [1] n_6: size_t [0, 1023]
23 [2] d_8: size_t [0, 1023]
25 Whereas evrp can't really:
26 [1] n_6: size_t [0, 9223372036854775805]
27 [2] d_8: size_t [0, 9223372036854775805]
29 This is causing the sprintf warning pass to issue a false
32 sprintf (b
, "%s.%s", s1
, s2
); // { dg-bogus "\\\[-Wformat-overflow" "" { xfail *-*-* } }
37 /* Extracted from gcc/c-cppbuiltin.c. */
39 void cpp_define (char*);
42 builtin_define_type_minmax (const char *min_macro
, const char *max_macro
,
45 extern const char *suffix
;
50 buf
= (char *) __builtin_alloca (__builtin_strlen (min_macro
) + 2
51 + __builtin_strlen (suffix
) + 1);
52 sprintf (buf
, "%s=0%s", min_macro
, suffix
); // { dg-bogus "\\\[-Wformat-overflow" }
56 buf
= (char *) __builtin_alloca (__builtin_strlen (min_macro
) + 3
57 + __builtin_strlen (max_macro
) + 6);
58 sprintf (buf
, "%s=(-%s - 1)", min_macro
, max_macro
); // { dg-bogus "\\\[-Wformat-overflow" }
65 c_cpp_builtins (void *type
)
68 builtin_define_type_minmax ("__WCHAR_MIN__", "__WCHAR_MAX__", type
);
69 builtin_define_type_minmax ("__WINT_MIN__", "__WINT_MAX__", type
);