| 1 |
// PR c++/71147 - [6 Regression] Flexible array member wrongly rejected |
| 2 |
// in template |
| 3 |
// { dg-do compile } |
| 4 |
// { dg-options "-Wpedantic -Wno-error=pedantic" } |
| 5 |
|
| 6 |
template <typename> |
| 7 |
struct container |
| 8 |
{ |
| 9 |
struct elem { |
| 10 |
unsigned u; |
| 11 |
}; |
| 12 |
|
| 13 |
struct incomplete { |
| 14 |
int x; |
| 15 |
elem array[]; // { dg-warning "10:ISO C\\+\\+ forbids flexible array member" } |
| 16 |
}; |
| 17 |
}; |
| 18 |
|
| 19 |
unsigned f (container<void>::incomplete* i) |
| 20 |
{ |
| 21 |
return i->array [0].u; |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
template <typename T> |
| 26 |
struct D: container<T> |
| 27 |
{ |
| 28 |
struct S { |
| 29 |
int x; |
| 30 |
typename container<T>::elem array[]; // { dg-warning "33:ISO C\\+\\+ forbids flexible array member" } |
| 31 |
}; |
| 32 |
}; |
| 33 |
|
| 34 |
|
| 35 |
unsigned g (D<void>::S *s) |
| 36 |
{ |
| 37 |
return s->array [0].u; |
| 38 |
} |