comparison gcc/testsuite/g++.dg/ipa/devirt-36.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 1830386684a0
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
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 struct C {int a; struct B b;};
5 void test2(struct A *);
6 int
7 m(struct B *b)
8 {
9 struct C *c = new (C);
10 struct A *a = &c->b;
11 a->t(); // This call should be devirtualized by
12 // FRE because we know type from ctor call
13 ((struct B *)a)->B::t(); // Make devirt possible
14 // C++ FE won't produce inline body without this
15 test2(a);
16 return a->t(); // This call should be devirtualized speculatively because
17 // test2 may change the type of A by placement new.
18 // C++ standard is bit imprecise about this.
19 }
20 /* { dg-final { scan-tree-dump "converting indirect call to function virtual int B::t" "fre1" } } */
21 /* { dg-final { scan-ipa-dump "to virtual int B::t" "devirt" } } */
22 /* { dg-final { scan-ipa-dump "1 speculatively devirtualized" "devirt" } } */
23