Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / gcc.dg / Wrestrict-10.c
blob8bdabdb033b5269a86e22e091485fac31038244b
1 /* PR tree-optimization/84526 - ICE in generic_overlap
2 { dg-do compile }
3 { dg-options "-O2 -Wrestrict" } */
5 typedef __SIZE_TYPE__ size_t;
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);
13 struct
15 char a[1];
16 } b;
18 int i;
19 size_t n;
21 void __attribute__ ((noclone, noinline))
22 test_arr_memcpy_1 (void)
24 memcpy (&b.a[i], b.a, n);
27 void __attribute__ ((noclone, noinline))
28 test_arr_memcpy_2 (void)
30 memcpy (b.a, &b.a[i], n);
33 void __attribute__ ((noclone, noinline))
34 test_arr_strcat_1 (void)
36 strcat (&b.a[i], b.a); /* { dg-warning "\\\[-Wrestrict" } */
39 void __attribute__ ((noclone, noinline))
40 test_arr_strcat_2 (void)
42 strcat (b.a, &b.a[i]); /* { dg-warning "\\\[-Wrestrict" } */
45 void __attribute__ ((noclone, noinline))
46 test_arr_strncat_1 (void)
48 strncat (&b.a[i], b.a, n); /* { dg-warning "\\\[-Wrestrict" } */
51 void __attribute__ ((noclone, noinline))
52 test_arr_strncat_2 (void)
54 strncat (b.a, &b.a[i], n); /* { dg-warning "\\\[-Wrestrict" } */
57 void __attribute__ ((noclone, noinline))
58 test_arr_strcpy_1 (void)
60 strcpy (&b.a[i], b.a); /* { dg-warning "\\\[-Wrestrict" } */
63 void __attribute__ ((noclone, noinline))
64 test_arr_strcpy_2 (void)
66 strcpy (b.a, &b.a[i]);
70 struct S {
71 int a;
72 char b[10];
73 } d;
75 void __attribute__ ((noclone, noinline))
76 test_obj_memcpy_1 (void)
78 memcpy (d.b, (char *) &d, n);
81 void __attribute__ ((noclone, noinline))
82 test_obj_memcpy_2 (void)
84 memcpy ((char *) &d, d.b, n);
87 void __attribute__ ((noclone, noinline))
88 test_obj_strcpy_1 (void)
90 strcpy (d.b, (char *) &d);
93 void __attribute__ ((noclone, noinline))
94 test_obj_strcpy_2 (void)
96 strcpy ((char *) &d, d.b);
99 void __attribute__ ((noclone, noinline))
100 test_obj_strncat_1 (void)
102 strncat (d.b, (char *) &d, n); /* { dg-warning "\\\[-Wrestrict" } */
105 void __attribute__ ((noclone, noinline))
106 test_obj_strncat_2 (void)
108 strncat ((char *) &d, d.b, n); /* { dg-warning "\\\[-Wrestrict" } */
111 void __attribute__ ((noclone, noinline))
112 test_obj_strncpy_1 (void)
114 strncpy (d.b, (char *) &d, n);
117 void test_obj_strncpy_2 (void)
119 strncpy ((char *) &d, d.b, n);