aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wstringop-truncation-9.c
blob: 63614809da4d7a12a6b56b6a960878ba9b275246 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* PR tree-optimization/99489 - ICE calling strncat after strncat
   { dg-do compile }
   { dg-options "-O2 -Wall" } */

// Important -- see pr82429.
char *stpcpy (char *, const char *);

void fchar (char *d, char c, char *s)
{
  __builtin_strcat (d, s);
  __builtin_strncat (d, &c, 1);
}

void fcstchar (char *d, char *s)
{
  __builtin_strcat (d, s);

  const char c = 'x';
  __builtin_strncat (d, &c, 1);     // { dg-warning "-Wstringop-truncation" }
}

void fstr (char *d, char *s)
{
  __builtin_strcat (d, s);
  __builtin_strncat (d, s, 1);
}

void farr (char *d, char *s)
{
  __builtin_strcat (d, s);

  char a[] = "x";
  __builtin_strncat (d, a, 1);      // { dg-warning "-Wstringop-truncation" }
}

void flit (char *d, char *s)
{
  __builtin_strcat (d, s);
  __builtin_strncat (d, "x", 1);    // { dg-warning "-Wstringop-truncation" "pr?????" { xfail *-*-*} }
                                    // { dg-warning "-Wstringop-overflow" "actual" { target *-*-*} .-1 }
}