| 1 |
/* We shall devirtualize to B::foo since it is the only live candidate of an |
| 2 |
anonymous type. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-O2 -fdump-ipa-whole-program-details" } */ |
| 5 |
namespace { |
| 6 |
class B { |
| 7 |
public: |
| 8 |
virtual int foo(void) |
| 9 |
{ |
| 10 |
return 0; |
| 11 |
} |
| 12 |
}; |
| 13 |
class A : public B { |
| 14 |
public: |
| 15 |
virtual int foo(void) |
| 16 |
{ |
| 17 |
return 1; |
| 18 |
} |
| 19 |
}; |
| 20 |
} |
| 21 |
class B *b; |
| 22 |
void get_me_lost (void *); |
| 23 |
int main() |
| 24 |
{ |
| 25 |
int c; |
| 26 |
if (c) |
| 27 |
{ |
| 28 |
class A a; |
| 29 |
a.foo(); |
| 30 |
} |
| 31 |
else |
| 32 |
{ |
| 33 |
b = new (class B); |
| 34 |
b->foo(); |
| 35 |
get_me_lost ((void *)&b); |
| 36 |
} |
| 37 |
return b->foo(); |
| 38 |
} |
| 39 |
|
| 40 |
/* { dg-final { scan-ipa-dump-not "builtin_unreachable" "whole-program"} } */ |
| 41 |
/* { dg-final { scan-ipa-dump "B::foo" "whole-program"} } */ |
| 42 |
/* { dg-final { scan-ipa-dump-not "A::foo" "whole-program"} } */ |