Debian Codegraph @

gcc/testsuite/gcc.dg/Wrestrict.c

raw
1 /* Test to verify that VLAs are handled gracefully by -Wrestrict
2 { dg-do compile }
3 { dg-options "-O2 -Wrestrict" } */
4
5 typedef __SIZE_TYPE__ size_t;
6
7 #define memcpy(d, s, n) __builtin_memcpy (d, s, n)
8 #define strcpy(d, s) __builtin_strcpy (d, s)
9
10 void test_vla (void *d, const char *s1, const char *s2, int i, size_t n)
11 {
12 char a[n];
13 char b[n];
14
15 strcpy (a, s1);
16 strcpy (b, s2);
17
18 memcpy (d, i ? a : b, n);
19 }
20
21
22 void test_vla_member (void *d, const char *s1, const char *s2, int i, size_t n)
23 {
24 struct S
25 {
26 char a[n];
27 char b[n];
28 } s;
29
30 strcpy (s.a, s1);
31 strcpy (s.b, s2);
32
33 memcpy (d, i ? s.a : s.b, n);
34 }