| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-Wvla-larger-than=100 -O2" } */ |
| 3 |
|
| 4 |
typedef __SIZE_TYPE__ size_t; |
| 5 |
|
| 6 |
extern void useit (char *); |
| 7 |
|
| 8 |
int num; |
| 9 |
|
| 10 |
void test_vlas (size_t num) |
| 11 |
{ |
| 12 |
char str2[num]; /* { dg-warning "unbounded use" } */ |
| 13 |
useit(str2); |
| 14 |
|
| 15 |
num = 98; |
| 16 |
for (int i=0; i < 1234; ++i) { |
| 17 |
char str[num]; // OK, VLA in a loop, but it is a |
| 18 |
// known size *AND* the compiler takes |
| 19 |
// care of cleaning up between |
| 20 |
// iterations with |
| 21 |
// __builtin_stack_restore. |
| 22 |
useit(str); |
| 23 |
} |
| 24 |
} |