| 1 |
// { dg-do run } |
| 2 |
// { dg-options "-O2 -fipa-cp-clone" } |
| 3 |
|
| 4 |
struct Distraction |
| 5 |
{ |
| 6 |
char fc[8]; |
| 7 |
virtual Distraction * return_self () |
| 8 |
{ return this; } |
| 9 |
}; |
| 10 |
|
| 11 |
static int go; |
| 12 |
|
| 13 |
struct A; |
| 14 |
|
| 15 |
struct A |
| 16 |
{ |
| 17 |
int fi; |
| 18 |
|
| 19 |
A () : fi(0) {} |
| 20 |
A (int pi) : fi (pi) {} |
| 21 |
virtual void foo (int p) = 0; |
| 22 |
}; |
| 23 |
|
| 24 |
struct B; |
| 25 |
|
| 26 |
struct B : public Distraction, A |
| 27 |
{ |
| 28 |
B () : Distraction(), A() { } |
| 29 |
B (int pi) : Distraction (), A (pi) {} |
| 30 |
virtual void foo (int p) |
| 31 |
{ |
| 32 |
int o = fi; |
| 33 |
for (int i = 0; i < p; i++) |
| 34 |
o += i + i * i; |
| 35 |
go = o; |
| 36 |
} |
| 37 |
}; |
| 38 |
|
| 39 |
struct B gb2 (2); |
| 40 |
|
| 41 |
extern "C" void abort (void); |
| 42 |
|
| 43 |
int |
| 44 |
main (void) |
| 45 |
{ |
| 46 |
for (int i = 0; i < 2; i++) |
| 47 |
{ |
| 48 |
struct A *p = &gb2; |
| 49 |
p->foo (0); |
| 50 |
if (go != 2) |
| 51 |
abort (); |
| 52 |
} |
| 53 |
return 0; |
| 54 |
} |