1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining -fdump-tree-optimized" } */
4 virtual int foo () {return 1;}
5 int bar () {return foo();}
9 struct B:A {virtual int foo () {return 2;}
10 int barbar () {return bar();}};
16 return static_cast<B*>(this)->barbar();
26 /* Inlining everything into main makes type clear from type of variable b.
27 However devirtualization is also possible for offline copy of A::barbar. Invoking
28 B's barbar makes it clear the type is at least B and B is an anonymous
29 namespace type and therefore we know it has no derivations. */
30 /* { dg-final { scan-ipa-dump "First type is base of second" "inline" } } */
31 /* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 2 "inline" } } */
33 /* Verify that speculation is optimized by late optimizers. */
34 /* { dg-final { scan-tree-dump-times "return 2" 3 "optimized" } } */
35 /* { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "optimized" } } */
37 /* { dg-final { cleanup-ipa-dump "inline" } } */
38 /* { dg-final { cleanup-tree-dump "optimized" } } */