| 1 |
// { dg-do run } |
| 2 |
// Copyright (C) 2000 Free Software Foundation, Inc. |
| 3 |
// Contributed by Nathan Sidwell 4 February 2001 <[email protected]> |
| 4 |
|
| 5 |
// Check primary bases are chosen correctly. |
| 6 |
|
| 7 |
struct A {virtual void Foo () {}}; |
| 8 |
struct B1 : virtual A {}; |
| 9 |
struct B2 : virtual A {}; |
| 10 |
struct C : virtual B1, B2 {}; |
| 11 |
struct D : virtual C {}; |
| 12 |
|
| 13 |
int main () |
| 14 |
{ |
| 15 |
C c; |
| 16 |
D d; |
| 17 |
|
| 18 |
A *apc = &c; |
| 19 |
B1 *b1pc = &c; |
| 20 |
B2 *b2pc = &c; |
| 21 |
|
| 22 |
A *apd = &d; |
| 23 |
B1 *b1pd = &d; |
| 24 |
B2 *b2pd = &d; |
| 25 |
C *cpd = &d; |
| 26 |
|
| 27 |
#if __GXX_ABI_VERSION >= 100 |
| 28 |
if (static_cast <void *> (apc) != static_cast <void *> (b1pc)) |
| 29 |
return 1; |
| 30 |
if (static_cast <void *> (&c) != static_cast <void *> (b2pc)) |
| 31 |
return 2; |
| 32 |
if (static_cast <void *> (b1pc) == static_cast <void *> (b2pc)) |
| 33 |
return 3; |
| 34 |
|
| 35 |
if (static_cast <void *> (apd) != static_cast <void *> (b1pd)) |
| 36 |
return 11; |
| 37 |
if (static_cast <void *> (b2pd) != static_cast <void *> (&d)) |
| 38 |
return 12; |
| 39 |
if (static_cast <void *> (b2pd) != static_cast <void *> (cpd)) |
| 40 |
return 13; |
| 41 |
if (static_cast <void *> (b1pd) == static_cast <void *> (b2pd)) |
| 42 |
return 14; |
| 43 |
#endif |
| 44 |
return 0; |
| 45 |
} |