| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O3 -fdump-tree-ccp1" } */ |
| 3 |
struct A |
| 4 |
{ |
| 5 |
int a; |
| 6 |
virtual int bar(void) {return a;} |
| 7 |
}; |
| 8 |
struct B |
| 9 |
{ |
| 10 |
virtual int foo(void) {return b;} |
| 11 |
int b; |
| 12 |
}; |
| 13 |
struct C: A,B |
| 14 |
{ |
| 15 |
virtual int foo(void) {return a;} |
| 16 |
}; |
| 17 |
|
| 18 |
struct C c; |
| 19 |
int test(void) |
| 20 |
{ |
| 21 |
struct C *d=&c; |
| 22 |
struct B *b=d; |
| 23 |
return d->foo()+b->foo(); |
| 24 |
} |
| 25 |
/* The call to b->foo() is perfectly devirtualizable because C can not be in construction |
| 26 |
when &c was used. */ |
| 27 |
/* { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "ccp1" } } */ |