| 1 |
// { dg-do run } |
| 2 |
|
| 3 |
#include <assert.h> |
| 4 |
struct A { |
| 5 |
A():value(123) {} |
| 6 |
int value; |
| 7 |
virtual int access() { return this->value; } |
| 8 |
}; |
| 9 |
struct B { |
| 10 |
B():value(456) {} |
| 11 |
int value; |
| 12 |
virtual int access() { return this->value; } |
| 13 |
}; |
| 14 |
struct C : public A, public B { |
| 15 |
C():better_value(789) {} |
| 16 |
int better_value; |
| 17 |
virtual int access() { return this->better_value; } |
| 18 |
}; |
| 19 |
struct D: public C { |
| 20 |
D():other_value(987) {} |
| 21 |
int other_value; |
| 22 |
virtual int access() { return this->other_value; } |
| 23 |
}; |
| 24 |
|
| 25 |
int use(B *b) |
| 26 |
{ |
| 27 |
return b->access(); |
| 28 |
} |
| 29 |
|
| 30 |
int main() |
| 31 |
{ |
| 32 |
C c; |
| 33 |
assert(use(&c) == 789); |
| 34 |
D d; |
| 35 |
assert(use(&d) == 987); |
| 36 |
return 0; |
| 37 |
} |