1 /* PR tree-optimization/85700 - Spurious -Wstringop-truncation warning
4 { dg-options "-O2 -Wno-stringop-overflow -Wstringop-truncation -ftrack-macro-expansion=0" } */
6 #define NOIPA __attribute__ ((noipa))
7 #define strncat __builtin_strncat
8 #define strlen __builtin_strlen
10 extern char a4
[4], b4
[4], ax
[];
12 NOIPA
void cat_a4_s1_1 (void)
14 /* There is no truncation here but since the bound of 1 equals
15 the length of the source string it's likely a mistake that
16 could cause overflow so it's diagnosed by -Wstringop-overflow */
20 NOIPA
void cat_a4_s1_2 (void)
25 NOIPA
void cat_a4_s1_3 (void)
30 NOIPA
void cat_a4_s1_4 (void)
32 /* There is no truncation here but since the bound of 1 equals
33 the length of the source string it's likely a mistake that
34 could cause overflow so it's diagnosed by -Wstringop-overflow */
38 NOIPA
void cat_a4_s1_5 (void)
40 /* A bound in excess of the destination size is diagnosed by
41 -Wstringop-overflow. */
45 NOIPA
void cat_a4_s1_dlen (void)
47 strncat (a4
, "1", sizeof a4
- strlen (a4
) - 1);
50 NOIPA
void cat_a4_s2_dlen (void)
52 strncat (a4
, "12", sizeof a4
- strlen (a4
) - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */
55 NOIPA
void cat_a4_b4_dlen (void)
57 strncat (a4
, b4
, sizeof a4
- strlen (a4
) - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */
60 NOIPA
void cat_ax_b4_dlen (void)
62 strncat (ax
, b4
, 32 - strlen (ax
) - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */