gcc/testsuite/g++.old-deja/g++.jason/ref10.C
raw| 1 | // { dg-do run } |
| 2 | // Test that conversion from D* to B*& works properly. |
| 3 | |
| 4 | extern "C" int printf (const char *, ...); |
| 5 | |
| 6 | struct V { |
| 7 | int a; |
| 8 | }; |
| 9 | |
| 10 | struct B: virtual V { |
| 11 | int b; |
| 12 | }; |
| 13 | |
| 14 | struct D: B { |
| 15 | int c; |
| 16 | }; |
| 17 | |
| 18 | V* gp = 0; |
| 19 | |
| 20 | void foo(V * const &r) { |
| 21 | gp = r; |
| 22 | } |
| 23 | |
| 24 | int bar(V *r) { |
| 25 | return (r != gp); |
| 26 | } |
| 27 | |
| 28 | int main() { |
| 29 | D *p = new D; |
| 30 | foo(p); |
| 31 | return bar(p); |
| 32 | } |