OSDN Git Service

PR c++/46124
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / ipa / ivinline-2.C
1 /* Verify that simple virtual calls using this pointer are inlined
2    even without early inlining..  */
3 /* { dg-do run } */
4 /* { dg-options "-O3 -fdump-ipa-inline -fno-early-inlining -fno-ipa-cp"  } */
5
6 extern "C" void abort (void);
7
8 class A
9 {
10 public:
11   int data;
12   virtual int foo (int i);
13   int middleman (int i)
14   {
15     return foo (i);
16   }
17 };
18
19 class B : public A
20 {
21 public:
22   virtual int foo (int i);
23 };
24
25 class C : public A
26 {
27 public:
28   virtual int foo (int i);
29 };
30
31 int A::foo (int i)
32 {
33   return i + 1;
34 }
35
36 int B::foo (int i)
37 {
38   return i + 2;
39 }
40
41 int C::foo (int i)
42 {
43   return i + 3;
44 }
45
46 int __attribute__ ((noinline,noclone)) get_input(void)
47 {
48   return 1;
49 }
50
51 int main (int argc, char *argv[])
52 {
53   class B b;
54   int i;
55
56   for (i = 0; i < get_input (); i++)
57     if (b.middleman (get_input ()) != 3)
58       abort ();
59   return 0;
60 }
61
62 /* { dg-final { scan-ipa-dump "B::foo\[^\\n\]*inline copy in int main"  "inline"  } } */
63 /* { dg-final { cleanup-ipa-dump "inline" } } */