2018-04-09 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / Wrestrict.c
blob266443fe25d4ef5a933444bd9e50fb50aadae2d0
1 /* Test to verify that VLAs are handled gracefully by -Wrestrict
2 { dg-do compile }
3 { dg-options "-O2 -Wrestrict" }
4 { dg-require-effective-target alloca } */
6 typedef __SIZE_TYPE__ size_t;
8 #define memcpy(d, s, n) __builtin_memcpy (d, s, n)
9 #define strcpy(d, s) __builtin_strcpy (d, s)
11 void test_vla (void *d, const char *s1, const char *s2, int i, size_t n)
13 char a[n];
14 char b[n];
16 strcpy (a, s1);
17 strcpy (b, s2);
19 memcpy (d, i ? a : b, n);
23 void test_vla_member (void *d, const char *s1, const char *s2, int i, size_t n)
25 struct S
27 char a[n];
28 char b[n];
29 } s;
31 strcpy (s.a, s1);
32 strcpy (s.b, s2);
34 memcpy (d, i ? s.a : s.b, n);