| 1 |
/* PR tree-optimization/89662- -Warray-bounds ICE on void* arithmetic |
| 2 |
{ dg-do compile } |
| 3 |
{ dg-options "-O2 -Wall" } */ |
| 4 |
|
| 5 |
static void* vptr (void *c) |
| 6 |
{ |
| 7 |
return c; |
| 8 |
} |
| 9 |
|
| 10 |
void sink (void*); |
| 11 |
|
| 12 |
void test_vptr_arith_vla_cst (void) |
| 13 |
{ |
| 14 |
int n = 1; |
| 15 |
char c[n]; |
| 16 |
sink (vptr (c) - 1); /* { dg-warning "\\\[-Warray-bounds" } */ |
| 17 |
} |
| 18 |
|
| 19 |
void test_vptr_arith_vla_range (int n) |
| 20 |
{ |
| 21 |
if (n < 1 || 4 < n) |
| 22 |
return; |
| 23 |
|
| 24 |
char c[n]; |
| 25 |
sink (vptr (c) - 1); /* { dg-warning "\\\[-Warray-bounds" "pr82608" { xfail *-*-* } } */ |
| 26 |
} |
| 27 |
|
| 28 |
void test_vptr_arith_vla_var (int n) |
| 29 |
{ |
| 30 |
char c[n]; |
| 31 |
sink (vptr (c) - 1); /* { dg-warning "\\\[-Warray-bounds" "pr82608" { xfail *-*-* } } */ |
| 32 |
} |