| 1 |
/* Check that we speculatively devirutalize call to FOO to B::foo becuase |
| 2 |
A is noreturn. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-O2 -fdump-ipa-devirt-details -fdump-tree-optimized" } */ |
| 5 |
/* { dg-add-options bind_pic_locally } */ |
| 6 |
|
| 7 |
class A { |
| 8 |
public: |
| 9 |
virtual int foo(void) |
| 10 |
{ |
| 11 |
throw (1); |
| 12 |
return 0; |
| 13 |
} |
| 14 |
}; |
| 15 |
|
| 16 |
|
| 17 |
class B : public A { |
| 18 |
public: |
| 19 |
virtual int foo(void); |
| 20 |
}; |
| 21 |
|
| 22 |
int |
| 23 |
B::foo(void) |
| 24 |
{ |
| 25 |
return 1; |
| 26 |
} |
| 27 |
class A a, *b=&a; |
| 28 |
void |
| 29 |
m(void) |
| 30 |
{ |
| 31 |
b->foo(); |
| 32 |
} |
| 33 |
int main() |
| 34 |
{ |
| 35 |
m(); |
| 36 |
} |
| 37 |
|
| 38 |
/* { dg-final { scan-ipa-dump "speculatively devirtualizing call" "devirt"} } */ |
| 39 |
/* Match if (PROF_6 == foo) to verify that the speculation survived. */ |
| 40 |
/* { dg-final { scan-tree-dump "== foo" "optimized"} } */ |