Fix test-suite fallout of default -Wreturn-type.
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / ivinline-9.C
blob41b2381877a60b97b3fc39dd9183390b2be2119c
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 and that ancestor itself has an ancestor wich is not the
4    primary base class.  */
5 /* { dg-do run { target nonpic } } */
6 /* { dg-options "-O3 -fdump-ipa-inline -fno-early-inlining -fno-ipa-cp"  } */
8 extern "C" void abort (void);
10 class Distraction
12 public:
13   float f;
14   double d;
15   Distraction ()
16   {
17     f = 8.3;
18     d = 10.2;
19   }
20   virtual float bar (float z);
23 class A
25 public:
26   int data;
27   virtual int foo (int i);
30 class D2
32 public:
33   virtual float baz (float z)
34   {
35     abort();
36   }
39 class A2 : public Distraction, public A
41   int i2;
44 class B : public A2
46 public:
47   virtual int foo (int i);
50 float Distraction::bar (float z)
52   f += z;
53   return f/2;
56 int A::foo (int i)
58   return i + 1;
61 int B::foo (int i)
63   return i + 2;
66 int __attribute__ ((noinline,noclone)) get_input(void)
68   return 1;
71 static int middleman_1 (class A *obj, int i)
73   return obj->foo (i);
76 static int middleman_2 (class B *obj, int i)
78   return middleman_1 (obj, i);
81 int main (int argc, char *argv[])
83   class B b;
84   int i;
86   for (i = 0; i < get_input (); i++)
87     if (middleman_2 (&b, get_input ()) != 3)
88       abort ();
89   return 0;
92 /* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*B::.*foo"  "inline"  } } */
93 /* { dg-final { scan-ipa-dump "B::foo\[^\\n\]*inline copy in int main"  "inline"  } } */