Rebase.
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / ivinline-4.C
blobf5b8f8e5dd49f4ec3f83e4d0565703148306065b
1 /* Verify that simple virtual calls are inlined even without early
2    inlining, even when a typecast to an ancestor is involved along the
3    way.  */
4 /* { dg-do run { target nonpic } } */
5 /* { dg-options "-O3 -fdump-ipa-inline -fno-early-inlining -fno-ipa-cp"  } */
7 extern "C" void abort (void);
9 class A
11 public:
12   int data;
13   virtual int foo (int i);
16 class B : public A
18 public:
19   virtual int foo (int i);
22 class C : public A
24 public:
25   virtual int foo (int i);
28 int A::foo (int i)
30   return i + 1;
33 int B::foo (int i)
35   return i + 2;
38 int C::foo (int i)
40   return i + 3;
43 int __attribute__ ((noinline,noclone)) get_input(void)
45   return 1;
48 static int middleman_1 (class A *obj, int i)
50   return obj->foo (i);
53 static int middleman_2 (class B *obj, int i)
55   return middleman_1 (obj, i);
58 int main (int argc, char *argv[])
60   class B b;
61   int i;
63   for (i = 0; i < get_input (); i++)
64     if (middleman_2 (&b, get_input ()) != 3)
65       abort ();
66   return 0;
69 /* { dg-final { scan-ipa-dump "B::foo\[^\\n\]*inline copy in int main"  "inline"  } } */
70 /* { dg-final { cleanup-ipa-dump "inline" } } */