.
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-44.C
blob5de761412d0560b15bfaf01bad184ee70e5990ef
1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining" } */
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;}};
10 void dostuff(struct A *);
12 static void
13 test (struct A *a)
15   dostuff (a);
16   if (a->foo ()!= 2)
17     __builtin_abort ();
20 int main()
22   struct B a;
23   dostuff (&a);
24   test (&a);
26 /* Here one invocation of foo is while type is in construction, while other is not.
27    Check that we handle that.  */
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"  } } */