Debian Codegraph @

gcc/testsuite/g++.dg/ipa/devirt-51.C

raw
1 /* Be sure we do not optimize the virtual call into call of the only non-virtual
2 variant. Either keeping virtual call or optimizing to cxa_pure_virtual
3 is fine. */
4 /* { dg-do compile } */
5 /* { dg-options "-O2 -fsanitize=unreachable -fdump-tree-optimized" } */
6 namespace {
7 struct B {
8 B* self;
9 B() : self( this ) { self->f(); }
10 void E(void);
11 virtual void f() = 0;
12 };
13
14 struct D : B
15 {
16 void f() {}
17 };
18 }
19
20 struct D e;
21
22 __attribute__ ((used))
23 void B::E(void)
24 {
25 this->f();
26 }
27
28 int main()
29 {
30 D d;
31 }
32 /* { dg-final { scan-tree-dump "cxa_pure_virtual" "optimized" } } */