OSDN Git Service

2010-05-19 Martin Jambor <mjambor@suse.cz>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / ipa / ivinline-8.C
1 /* Verify that virtual calls are inlined (ithout early inlining) even
2    when their caller is itself indirectly inlined.  */
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 bar (int i);
13   virtual int foo (int i);
14 };
15
16 class B : public A
17 {
18 public:
19   virtual int bar (int i);
20   virtual int foo (int i);
21 };
22
23 class C : public A
24 {
25 public:
26   virtual int foo (int i);
27 };
28
29 int A::bar (int i)
30 {
31   return i + 100 * i;
32 }
33
34 int A::foo (int i)
35 {
36   return bar (i) + 1;
37 }
38
39 int B::bar (int i)
40 {
41   return i + 100 * (i + 2);
42 }
43
44 int B::foo (int i)
45 {
46   return bar (i) + 2;
47 }
48
49 int C::foo (int i)
50 {
51   return i + 3;
52 }
53
54 int middleman (class A *obj, int i)
55 {
56   return obj->foo (i);
57 }
58
59 int __attribute__ ((noinline,noclone)) get_input(void)
60 {
61   return 1;
62 }
63
64 int main (int argc, char *argv[])
65 {
66   class B b;
67   int i;
68
69   for (i = 0; i < get_input (); i++)
70     if (middleman (&b, get_input ()) != 303)
71       abort ();
72   return 0;
73 }
74
75 /* { dg-final { scan-ipa-dump "B::foo\[^\\n\]*inline copy in int main" "inline"  } } */
76 /* { dg-final { scan-ipa-dump "B::bar\[^\\n\]*inline copy in int main" "inline"  } } */
77 /* { dg-final { cleanup-ipa-dump "inline" } } */