| 1 |
/* { dg-options "-O2 -msoft-stack" } */ |
| 2 |
/* { dg-do run } */ |
| 3 |
|
| 4 |
/* See also 'gcc.target/nvptx/alloca-5.c'. */ |
| 5 |
|
| 6 |
static __attribute__((noinline,noclone)) int f(int *p) |
| 7 |
{ |
| 8 |
return __sync_lock_test_and_set(p, 1); |
| 9 |
} |
| 10 |
|
| 11 |
static __attribute__((noinline,noclone)) int g(int n) |
| 12 |
{ |
| 13 |
/* Check that variable-length stack allocation works. */ |
| 14 |
int v[n]; |
| 15 |
v[0] = 0; |
| 16 |
/* Check that atomic operations can be applied to auto data. */ |
| 17 |
return f(v) == 0 && v[0] == 1; |
| 18 |
} |
| 19 |
|
| 20 |
int main() |
| 21 |
{ |
| 22 |
if (!g(1)) |
| 23 |
__builtin_abort(); |
| 24 |
return 0; |
| 25 |
} |