Debian Codegraph @

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

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining -fno-implicit-constexpr" } */
3 struct A {
4 virtual int foo () {return 1;}
5 void wrapfoo () {foo();}
6 A() {wrapfoo();}
7 };
8 struct B:A {virtual int foo () {return 2;}};
9
10 void dostuff(struct A *);
11
12 static void
13 test (struct A *a)
14 {
15 dostuff (a);
16 if (a->foo ()!= 2)
17 __builtin_abort ();
18 }
19
20 int main()
21 {
22 struct B a;
23 dostuff (&a);
24 test (&a);
25 }
26 /* Here one invocation of foo is while type is in construction, while other is not.
27 Check that we handle that. */
28
29 /* { dg-final { scan-ipa-dump "Second type is base of first" "inline" } } */
30 /* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*A::foo" 1 "inline" } } */
31 /* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*B::foo" 1 "inline" } } */