1 /* PR tree-optimization/99489 - ICE calling strncat after strncat
2 { dg-do compile }
3 { dg-options "-O2 -Wall" } */
4
5 // Important -- see pr82429.
6 char *stpcpy (char *, const char *);
7
8 void fchar (char *d, char c, char *s)
9 {
10 __builtin_strcat (d, s);
11 __builtin_strncat (d, &c, 1);
12 }
13
14 void fcstchar (char *d, char *s)
15 {
16 __builtin_strcat (d, s);
17
18 const char c = 'x';
19 __builtin_strncat (d, &c, 1); // { dg-warning "-Wstringop-truncation" }
20 }
21
22 void fstr (char *d, char *s)
23 {
24 __builtin_strcat (d, s);
25 __builtin_strncat (d, s, 1);
26 }
27
28 void farr (char *d, char *s)
29 {
30 __builtin_strcat (d, s);
31
32 char a[] = "x";
33 __builtin_strncat (d, a, 1); // { dg-warning "-Wstringop-truncation" }
34 }
35
36 void flit (char *d, char *s)
37 {
38 __builtin_strcat (d, s);
39 __builtin_strncat (d, "x", 1); // { dg-warning "-Wstringop-truncation" "pr?????" { xfail *-*-*} }
40 // { dg-warning "-Wstringop-overflow" "actual" { target *-*-*} .-1 }
41 }