gcc/testsuite/g++.old-deja/g++.pt/vbase1.C
raw| 1 | // { dg-do run } |
| 2 | // Check that template classes handle inherited virtual bases |
| 3 | // properly, initializing them before direct non-virtual bases. |
| 4 | |
| 5 | extern "C" void exit (int); |
| 6 | |
| 7 | int aflag; |
| 8 | |
| 9 | struct A |
| 10 | { |
| 11 | A() { aflag = 1; } |
| 12 | }; |
| 13 | |
| 14 | struct B : virtual public A |
| 15 | { |
| 16 | B() { } |
| 17 | }; |
| 18 | |
| 19 | struct C |
| 20 | { |
| 21 | C() { if (!aflag) exit (1); } |
| 22 | }; |
| 23 | |
| 24 | template<class Parent> |
| 25 | struct D : public C, public Parent |
| 26 | { |
| 27 | D() { } |
| 28 | }; |
| 29 | |
| 30 | int |
| 31 | main () |
| 32 | { |
| 33 | D<B> c; |
| 34 | } |