1 /* PR middle-end/100571 - bogus -Wstringop-overflow with VLA of elements
2 larger than byte
3 { dg-do compile }
4 { dg-options "-O2 -Wall" }
5 { dg-require-effective-target alloca } */
6
7 __attribute__ ((access (read_only, 1, 2))) void fro (int *, int);
8 __attribute__ ((access (write_only, 1, 2))) void fwo (int *, int);
9 __attribute__ ((access (read_write, 1, 2))) void frw (int *, int);
10
11 extern __SIZE_TYPE__ n;
12
13 void alloca_ro (void)
14 {
15 int *a = __builtin_alloca (n * sizeof *a);
16 a[0] = 0;
17 fro (a, n);
18 }
19
20 void alloca_wo (void)
21 {
22 int *a = __builtin_alloca (n * sizeof *a);
23 fwo (a, n);
24 }
25
26 void alloca_rw (void)
27 {
28 int *a = __builtin_alloca (n * sizeof *a);
29 a[0] = 0;
30 frw (a, n);
31 }
32
33
34 void calloc_ro (void)
35 {
36 int *a = __builtin_calloc (n, sizeof *a);
37 fro (a, n);
38 }
39
40 void calloc_wo (void)
41 {
42 int *a = __builtin_calloc (n, sizeof *a);
43 fwo (a, n);
44 }
45
46 void calloc_rw (void)
47 {
48 int *a = __builtin_calloc (n, sizeof *a);
49 a[0] = 0;
50 frw (a, n);
51 }
52
53
54 void malloc_ro (void)
55 {
56 int *a = __builtin_malloc (n * sizeof *a);
57 a[0] = 0;
58 fro (a, n);
59 }
60
61 void malloc_wo (void)
62 {
63 int *a = __builtin_malloc (n * sizeof *a);
64 fwo (a, n);
65 }
66
67 void malloc_rw (void)
68 {
69 int *a = __builtin_malloc (n * sizeof *a);
70 a[0] = 0;
71 frw (a, n);
72 }
73
74
75 void vla_ro (void)
76 {
77 int a[n];
78 a[0] = 0;
79 fro (a, n);
80 }
81
82 void vla_wo (void)
83 {
84 int a[n];
85 fwo (a, n);
86 }
87
88 void vla_rw (void)
89 {
90 int a[n];
91 a[0] = 0;
92 frw (a, n);
93 }