| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-Walloca-larger-than=2000 -O2" } */ |
| 3 |
|
| 4 |
// Test when the conditionals are incorrectly reversed. |
| 5 |
|
| 6 |
void f (void *); |
| 7 |
void foo (__SIZE_TYPE__ len) |
| 8 |
{ |
| 9 |
void *p; |
| 10 |
if (len < 500) |
| 11 |
p = __builtin_malloc (len); |
| 12 |
else |
| 13 |
p = __builtin_alloca (len); // { dg-warning "argument to .alloca. may be too large" } |
| 14 |
f (p); |
| 15 |
} |
| 16 |
|
| 17 |
void bar (__SIZE_TYPE__ len) |
| 18 |
{ |
| 19 |
void *p; |
| 20 |
if (len > 500) |
| 21 |
p = __builtin_alloca (len); // { dg-warning "argument to .alloca. may be too large" } |
| 22 |
else |
| 23 |
p = __builtin_malloc (len); |
| 24 |
f (p); |
| 25 |
} |