PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / Wrestrict-15.c
blobb0b30a2baece9891da8786e50631586ff78b345f
1 /* PR 85365 - -Wrestrict false positives with -fsanitize=undefined
2 { dg-do compile }
3 { dg-options "-O2 -Wrestrict -fsanitize=undefined" } */
5 typedef __SIZE_TYPE__ size_t;
7 char *strcpy (char *, const char *);
8 char *strcat (char *, const char *);
10 size_t strlen (char *);
12 extern char a[], b[], d[];
14 size_t t1 (char *g, int i)
16 /* The following exercises the handling in gimple-fold.c. */
17 strcpy (g + 4, i ? b : a); /* { dg-bogus "\\\[-Wrestrict]" } */
18 return strlen (g + 4);
21 void t2 (char *g, int i)
23 strcpy (g + 4, i ? b : a); /* { dg-bogus "\\\[-Wrestrict]" } */
24 strcat (g + 4, d);
27 void t3 (char *g, int i)
29 /* The following exercises the handling in gimple-ssa-warn-restrict.c. */
30 strcat (g + 4, i ? b : a); /* { dg-bogus "\\\[-Wrestrict]" } */
31 strcat (g + 4, d);
34 void t4 (char *p, char *q)
36 strcpy (p, q); /* { dg-bogus "\\\[-Wrestrict]" } */
37 strcat (p, q + 32);