Fix test-suite fallout of default -Wreturn-type.
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-5.C
blobdb48c6896857da22c9d0b5c2d294690dd664b991
1 /* Verify that ipa-cp can convert simple virtual calls to a direct
2    ones even when a typecast to an ancestor is involved along the way
3    and that ancestor is not the first one with virtual functions.  */
4 /* { dg-do run } */
5 /* { dg-options "-O3 -fno-early-inlining -fno-inline -fdump-ipa-cp -fdump-tree-optimized"  } */
7 extern "C" void abort (void);
9 class Distraction
11 public:
12   float f;
13   double d;
14   Distraction ()
15   {
16     f = 8.3;
17     d = 10.2;
18   }
19   virtual float bar (float z);
22 class A
24 public:
25   int data;
26   virtual int foo (int i);
30 class B : public Distraction, public A
32 public:
33   virtual int foo (int i);
36 float Distraction::bar (float z)
38   f += z;
39   return f/2;
42 int A::foo (int i)
44   return i + 1;
47 int B::foo (int i)
49   return i + 2;
52 int __attribute__ ((noinline,noclone)) get_input(void)
54   return 1;
57 static int middleman_1 (class A *obj, int i)
59   return obj->foo (i);
62 static int middleman_2 (class B *obj, int i)
64   return middleman_1 (obj, i);
67 int main (int argc, char *argv[])
69   class B b;
71   if (middleman_2 (&b, get_input ()) != 3)
72     abort ();
73   return 0;
76 /* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*B::foo"  "cp"  } } */
77 /* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "optimized"} } */