1 /* { dg-options "-O2 -fdump-ipa-devirt-details -fdump-tree-fre1-details" } */
2 struct A {virtual int t(void) {return 1;}};
3 struct B:A {B(); virtual int t(void) {return 2;}};
4 void test2(struct A *);
9 a->t(); // This call should be devirtualized by
10 // FRE because we know type from ctor call
11 ((struct B *)a)->B::t(); // Make devirt possible
12 // C++ FE won't produce inline body without this
14 return a->t(); // This call should be devirtualized speculatively because
15 // test2 may change the type of A by placement new.
16 // C++ standard is bit imprecise about this.
18 /* { dg-final { scan-tree-dump "converting indirect call to function virtual int B::t" "fre1" } } */
19 /* { dg-final { scan-ipa-dump "to virtual int B::t" "devirt" } } */
20 /* { dg-final { scan-ipa-dump "1 speculatively devirtualized" "devirt" } } */