| 1 |
/* PR middle-end/97189 - ICE on redeclaration of a function with VLA argument |
| 2 |
and attribute access |
| 3 |
{ dg-do compile } |
| 4 |
{ dg-options "-Wall" } */ |
| 5 |
|
| 6 |
#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) |
| 7 |
|
| 8 |
RW (2, 3) void f1 (int n, int[n], int); |
| 9 |
/* { dg-warning "attribute 'access \\(read_write, 2, 3\\)' positional argument 2 conflicts with previous designation by argument 3" "warning" { target *-*-* } .-1 } |
| 10 |
{ dg-message "designating the bound of variable length array argument 2" "note" { target *-*-* } .-2 } */ |
| 11 |
|
| 12 |
void call_f1 (int *p) |
| 13 |
{ |
| 14 |
/* Verify that a warning is issued. Ideally, it seems the VLA bound |
| 15 |
should take precedence over the attribute and the warning would |
| 16 |
reference argument 1 but since the conflict in the redeclarations |
| 17 |
of the function is already diagnosed don't test that (and let it |
| 18 |
be acceptable for this warning to reference argument 3). */ |
| 19 |
f1 (-1, p, -1); |
| 20 |
// { dg-warning "argument \\d value -1 is negative" "warning" { target *-*-* } .-1 } |
| 21 |
} |
| 22 |
|
| 23 |
RW (2) void f2 (int, int[*], int); |
| 24 |
// { dg-message "previously declared as a variable length array 'int\\\[\\\*]'" "note" { target *-*-* } .-1 } |
| 25 |
RW (2, 3) void f2 (int, int[], int); |
| 26 |
// { dg-warning "argument 2 of type 'int\\\[]' declared as an ordinary array" "warning" { target *-*-* } .-1 } |
| 27 |
|
| 28 |
void call_f2 (int *p) |
| 29 |
{ |
| 30 |
f2 (-1, p, 0); |
| 31 |
|
| 32 |
/* Verify that the attribute access on the redeclaration of f2() takes |
| 33 |
precedence over the one on the first declaration. */ |
| 34 |
f2 (0, p, -1); |
| 35 |
// { dg-warning "argument 3 value -1 is negative" "warning" { target *-*-* } .-1 } |
| 36 |
} |