| 1 |
/* PR tree-optimization/84526 - ICE in generic_overlap |
| 2 |
{ dg-do compile } |
| 3 |
{ dg-options "-O2 -Wrestrict" } */ |
| 4 |
|
| 5 |
typedef __SIZE_TYPE__ size_t; |
| 6 |
|
| 7 |
extern void* memcpy (void* restrict, const void* restrict, size_t); |
| 8 |
extern char* strcat (char* restrict, const char* restrict); |
| 9 |
extern char* strcpy (char* restrict, const char* restrict); |
| 10 |
extern char* strncat (char* restrict, const char* restrict, size_t); |
| 11 |
extern char* strncpy (char* restrict, const char* restrict, size_t); |
| 12 |
|
| 13 |
struct |
| 14 |
{ |
| 15 |
char a[1]; |
| 16 |
} b; |
| 17 |
|
| 18 |
int i; |
| 19 |
size_t n; |
| 20 |
|
| 21 |
void __attribute__ ((noclone, noinline)) |
| 22 |
test_arr_memcpy_1 (void) |
| 23 |
{ |
| 24 |
memcpy (&b.a[i], b.a, n); |
| 25 |
} |
| 26 |
|
| 27 |
void __attribute__ ((noclone, noinline)) |
| 28 |
test_arr_memcpy_2 (void) |
| 29 |
{ |
| 30 |
memcpy (b.a, &b.a[i], n); |
| 31 |
} |
| 32 |
|
| 33 |
void __attribute__ ((noclone, noinline)) |
| 34 |
test_arr_strcat_1 (void) |
| 35 |
{ |
| 36 |
strcat (&b.a[i], b.a); /* { dg-warning "\\\[-Wrestrict" } */ |
| 37 |
} |
| 38 |
|
| 39 |
void __attribute__ ((noclone, noinline)) |
| 40 |
test_arr_strcat_2 (void) |
| 41 |
{ |
| 42 |
strcat (b.a, &b.a[i]); /* { dg-warning "\\\[-Wrestrict" } */ |
| 43 |
} |
| 44 |
|
| 45 |
void __attribute__ ((noclone, noinline)) |
| 46 |
test_arr_strncat_1 (void) |
| 47 |
{ |
| 48 |
strncat (&b.a[i], b.a, n); /* { dg-warning "\\\[-Wrestrict" } */ |
| 49 |
} |
| 50 |
|
| 51 |
void __attribute__ ((noclone, noinline)) |
| 52 |
test_arr_strncat_2 (void) |
| 53 |
{ |
| 54 |
strncat (b.a, &b.a[i], n); /* { dg-warning "\\\[-Wrestrict" } */ |
| 55 |
} |
| 56 |
|
| 57 |
void __attribute__ ((noclone, noinline)) |
| 58 |
test_arr_strcpy_1 (void) |
| 59 |
{ |
| 60 |
strcpy (&b.a[i], b.a); /* { dg-warning "\\\[-Wrestrict" } */ |
| 61 |
} |
| 62 |
|
| 63 |
void __attribute__ ((noclone, noinline)) |
| 64 |
test_arr_strcpy_2 (void) |
| 65 |
{ |
| 66 |
strcpy (b.a, &b.a[i]); /* { dg-warning "\\\[-Wrestrict" } */ |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
struct S { |
| 71 |
int a; |
| 72 |
char b[10]; |
| 73 |
} d; |
| 74 |
|
| 75 |
void __attribute__ ((noclone, noinline)) |
| 76 |
test_obj_memcpy_1 (void) |
| 77 |
{ |
| 78 |
memcpy (d.b, (char *) &d, n); |
| 79 |
} |
| 80 |
|
| 81 |
void __attribute__ ((noclone, noinline)) |
| 82 |
test_obj_memcpy_2 (void) |
| 83 |
{ |
| 84 |
memcpy ((char *) &d, d.b, n); |
| 85 |
} |
| 86 |
|
| 87 |
void __attribute__ ((noclone, noinline)) |
| 88 |
test_obj_strcpy_1 (void) |
| 89 |
{ |
| 90 |
strcpy (d.b, (char *) &d); |
| 91 |
} |
| 92 |
|
| 93 |
void __attribute__ ((noclone, noinline)) |
| 94 |
test_obj_strcpy_2 (void) |
| 95 |
{ |
| 96 |
strcpy ((char *) &d, d.b); |
| 97 |
} |
| 98 |
|
| 99 |
void __attribute__ ((noclone, noinline)) |
| 100 |
test_obj_strncat_1 (void) |
| 101 |
{ |
| 102 |
strncat (d.b, (char *) &d, n); /* { dg-warning "\\\[-Wrestrict" } */ |
| 103 |
} |
| 104 |
|
| 105 |
void __attribute__ ((noclone, noinline)) |
| 106 |
test_obj_strncat_2 (void) |
| 107 |
{ |
| 108 |
strncat ((char *) &d, d.b, n); /* { dg-warning "\\\[-Wrestrict" } */ |
| 109 |
} |
| 110 |
|
| 111 |
void __attribute__ ((noclone, noinline)) |
| 112 |
test_obj_strncpy_1 (void) |
| 113 |
{ |
| 114 |
strncpy (d.b, (char *) &d, n); |
| 115 |
} |
| 116 |
|
| 117 |
void test_obj_strncpy_2 (void) |
| 118 |
{ |
| 119 |
strncpy ((char *) &d, d.b, n); |
| 120 |
} |