gcc/testsuite/g++.dg/cpp0x/nsdmi-virtual1.C
raw| 1 | // PR c++/51611 |
| 2 | // { dg-do run { target c++11 } } |
| 3 | |
| 4 | struct A |
| 5 | { |
| 6 | A(): i(42) { } |
| 7 | int i; |
| 8 | int f() { return i; } |
| 9 | }; |
| 10 | |
| 11 | struct B : virtual A |
| 12 | { |
| 13 | int j = i + f(); |
| 14 | int k = A::i + A::f(); |
| 15 | }; |
| 16 | |
| 17 | struct C: B { int pad; }; |
| 18 | |
| 19 | int main() |
| 20 | { |
| 21 | C c; |
| 22 | if (c.j != 84 || c.k != 84) |
| 23 | __builtin_abort(); |
| 24 | } |
| 25 |