| 1 |
/* PR middle-end/98266 - bogus array subscript is partly outside array |
| 2 |
bounds on virtual inheritance |
| 3 |
{ dg-do compile } |
| 4 |
{ dg-options "-O2 -Wall" } */ |
| 5 |
|
| 6 |
#if __cplusplus < 201103L |
| 7 |
// This matters for the test case. |
| 8 |
# define noexcept throw () |
| 9 |
#endif |
| 10 |
|
| 11 |
struct A |
| 12 |
{ |
| 13 |
virtual ~A () noexcept; |
| 14 |
const char *s; |
| 15 |
}; |
| 16 |
|
| 17 |
struct B: virtual A { }; |
| 18 |
struct C: virtual A { }; // { dg-bogus "\\\[-Warray-bounds" } |
| 19 |
|
| 20 |
struct D: virtual B, virtual C |
| 21 |
{ |
| 22 |
D (const char*); |
| 23 |
}; |
| 24 |
|
| 25 |
void sink (void*); |
| 26 |
void sink (D); |
| 27 |
|
| 28 |
|
| 29 |
// Verify that accesses to the table aren't diagnosed. |
| 30 |
void test_vtbl () |
| 31 |
{ |
| 32 |
sink (D ("")); |
| 33 |
} |