| 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 |
|
| 6 |
__attribute__ ((access (read_only, 1, 2))) void fro (int *, int); |
| 7 |
__attribute__ ((access (write_only, 1, 2))) void fwo (int *, int); |
| 8 |
__attribute__ ((access (read_write, 1, 2))) void frw (int *, int); |
| 9 |
|
| 10 |
extern __SIZE_TYPE__ n; |
| 11 |
|
| 12 |
void alloca_ro (void) |
| 13 |
{ |
| 14 |
int *a = __builtin_alloca (n * sizeof *a); |
| 15 |
a[0] = 0; |
| 16 |
fro (a, n); |
| 17 |
} |
| 18 |
|
| 19 |
void alloca_wo (void) |
| 20 |
{ |
| 21 |
int *a = __builtin_alloca (n * sizeof *a); |
| 22 |
fwo (a, n); |
| 23 |
} |
| 24 |
|
| 25 |
void alloca_rw (void) |
| 26 |
{ |
| 27 |
int *a = __builtin_alloca (n * sizeof *a); |
| 28 |
a[0] = 0; |
| 29 |
frw (a, n); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
void calloc_ro (void) |
| 34 |
{ |
| 35 |
int *a = __builtin_calloc (n, sizeof *a); |
| 36 |
fro (a, n); |
| 37 |
} |
| 38 |
|
| 39 |
void calloc_wo (void) |
| 40 |
{ |
| 41 |
int *a = __builtin_calloc (n, sizeof *a); |
| 42 |
fwo (a, n); |
| 43 |
} |
| 44 |
|
| 45 |
void calloc_rw (void) |
| 46 |
{ |
| 47 |
int *a = __builtin_calloc (n, sizeof *a); |
| 48 |
a[0] = 0; |
| 49 |
frw (a, n); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
void malloc_ro (void) |
| 54 |
{ |
| 55 |
int *a = __builtin_malloc (n * sizeof *a); |
| 56 |
a[0] = 0; |
| 57 |
fro (a, n); |
| 58 |
} |
| 59 |
|
| 60 |
void malloc_wo (void) |
| 61 |
{ |
| 62 |
int *a = __builtin_malloc (n * sizeof *a); |
| 63 |
fwo (a, n); |
| 64 |
} |
| 65 |
|
| 66 |
void malloc_rw (void) |
| 67 |
{ |
| 68 |
int *a = __builtin_malloc (n * sizeof *a); |
| 69 |
a[0] = 0; |
| 70 |
frw (a, n); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
void vla_ro (void) |
| 75 |
{ |
| 76 |
int a[n]; |
| 77 |
a[0] = 0; |
| 78 |
fro (a, n); |
| 79 |
} |
| 80 |
|
| 81 |
void vla_wo (void) |
| 82 |
{ |
| 83 |
int a[n]; |
| 84 |
fwo (a, n); |
| 85 |
} |
| 86 |
|
| 87 |
void vla_rw (void) |
| 88 |
{ |
| 89 |
int a[n]; |
| 90 |
a[0] = 0; |
| 91 |
frw (a, n); |
| 92 |
} |