| 1 |
// { dg-do run } |
| 2 |
// GROUPS passed virtual-tables |
| 3 |
// Check that virtual function tables are generated and used |
| 4 |
// even for struct's/classes which have no explicit constructors. |
| 5 |
|
| 6 |
extern "C" int printf (const char *, ...); |
| 7 |
|
| 8 |
int base_func_member_1_called = 0; |
| 9 |
int derived_func_member_1_called = 0; |
| 10 |
|
| 11 |
struct base { |
| 12 |
virtual void func_member_1 () |
| 13 |
{ |
| 14 |
base_func_member_1_called++; |
| 15 |
} |
| 16 |
}; |
| 17 |
|
| 18 |
struct derived : public base { |
| 19 |
virtual void func_member_1 () |
| 20 |
{ |
| 21 |
derived_func_member_1_called++; |
| 22 |
} |
| 23 |
|
| 24 |
virtual void func_member_2 () |
| 25 |
{ |
| 26 |
} |
| 27 |
}; |
| 28 |
|
| 29 |
base* bp1; |
| 30 |
base* bp2; |
| 31 |
|
| 32 |
int main () |
| 33 |
{ |
| 34 |
bp1 = new base; |
| 35 |
bp2 = new derived; |
| 36 |
|
| 37 |
bp1->func_member_1 (); |
| 38 |
bp2->func_member_1 (); |
| 39 |
|
| 40 |
printf ("PASS\n"); |
| 41 |
|
| 42 |
return 0; |
| 43 |
} |