| 1 |
/* PR 85365 - -Wrestrict false positives with -fsanitize=undefined |
| 2 |
{ dg-do compile } |
| 3 |
{ dg-options "-O2 -Wrestrict -fsanitize=undefined" } */ |
| 4 |
|
| 5 |
typedef __SIZE_TYPE__ size_t; |
| 6 |
|
| 7 |
char *strcpy (char *, const char *); |
| 8 |
char *strcat (char *, const char *); |
| 9 |
|
| 10 |
size_t strlen (char *); |
| 11 |
|
| 12 |
extern char a[], b[], d[]; |
| 13 |
|
| 14 |
size_t t1 (char *g, int i) |
| 15 |
{ |
| 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); |
| 19 |
} |
| 20 |
|
| 21 |
void t2 (char *g, int i) |
| 22 |
{ |
| 23 |
strcpy (g + 4, i ? b : a); /* { dg-bogus "\\\[-Wrestrict]" } */ |
| 24 |
strcat (g + 4, d); |
| 25 |
} |
| 26 |
|
| 27 |
void t3 (char *g, int i) |
| 28 |
{ |
| 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); |
| 32 |
} |
| 33 |
|
| 34 |
void t4 (char *p, char *q) |
| 35 |
{ |
| 36 |
strcpy (p, q); /* { dg-bogus "\\\[-Wrestrict]" } */ |
| 37 |
strcat (p, q + 32); |
| 38 |
} |