131
|
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 } */
|
|
5
|
|
6 typedef __SIZE_TYPE__ size_t;
|
|
7
|
|
8 #define memcpy(d, s, n) __builtin_memcpy (d, s, n)
|
|
9 #define strcpy(d, s) __builtin_strcpy (d, s)
|
|
10
|
|
11 void test_vla (void *d, const char *s1, const char *s2, int i, size_t n)
|
|
12 {
|
|
13 char a[n];
|
|
14 char b[n];
|
|
15
|
|
16 strcpy (a, s1);
|
|
17 strcpy (b, s2);
|
|
18
|
|
19 memcpy (d, i ? a : b, n);
|
|
20 }
|
|
21
|
|
22
|
|
23 void test_vla_member (void *d, const char *s1, const char *s2, int i, size_t n)
|
|
24 {
|
|
25 struct S
|
|
26 {
|
|
27 char a[n];
|
|
28 char b[n];
|
|
29 } s;
|
|
30
|
|
31 strcpy (s.a, s1);
|
|
32 strcpy (s.b, s2);
|
|
33
|
|
34 memcpy (d, i ? s.a : s.b, n);
|
|
35 }
|