| 1 |
// { dg-do run } |
| 2 |
|
| 3 |
// Copyright (C) 2005 Free Software Foundation, Inc. |
| 4 |
// Contributed by Nathan Sidwell 11 Feb 2005 <[email protected]> |
| 5 |
|
| 6 |
// Origin: [email protected] |
| 7 |
// Bug 19891: Incorrect covariant vtables |
| 8 |
|
| 9 |
struct Model { |
| 10 |
bool full_tree; |
| 11 |
virtual Model* clone() const =0; |
| 12 |
virtual const char *name() const =0; |
| 13 |
virtual ~Model() {} |
| 14 |
}; |
| 15 |
|
| 16 |
struct R: virtual public Model { |
| 17 |
virtual R* clone() const =0; |
| 18 |
}; |
| 19 |
struct A: virtual public Model { |
| 20 |
virtual A* clone() const=0; |
| 21 |
}; |
| 22 |
struct RA: public R, public A { |
| 23 |
virtual RA* clone() const=0; |
| 24 |
}; |
| 25 |
|
| 26 |
static const char *string = "EQU"; |
| 27 |
|
| 28 |
struct EQU: public RA { |
| 29 |
virtual EQU* clone() const {return new EQU(*this);} |
| 30 |
const char *name() const {return string;} |
| 31 |
}; |
| 32 |
|
| 33 |
int main() { |
| 34 |
Model* M1 = new EQU(); |
| 35 |
Model* M2 = M1->clone(); |
| 36 |
Model* M3 = M2->clone(); |
| 37 |
|
| 38 |
if (M1->name () != string) |
| 39 |
return 1; |
| 40 |
if (M2->name () != string) |
| 41 |
return 2; |
| 42 |
if (M3->name () != string) |
| 43 |
return 3; |
| 44 |
|
| 45 |
return 0; |
| 46 |
} |