Fix test-suite fallout of default -Wreturn-type.
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-c-3.C
blobc8791f79e64f859dea609b60cc8e6b6eb013be75
1 /* Verify that ipa-cp correctly detects the dynamic type of an object
2    under construction when doing devirtualization.  */
3 /* { dg-do run } */
4 /* { dg-options "-O3 -fno-inline"  } */
6 extern "C" void abort (void);
8 class Distraction
10 public:
11   float f;
12   double d;
13   Distraction ()
14   {
15     f = 8.3;
16     d = 10.2;
17   }
18   virtual float bar (float z);
21 class A
23 public:
24   int data;
25   A();
26   virtual int foo (int i);
29 class B : public Distraction, public A
31 public:
32   virtual int foo (int i);
35 float Distraction::bar (float z)
37   f += z;
38   return f/2;
41 int A::foo (int i)
43   return i + 1;
46 int B::foo (int i)
48   return i + 2;
51 int __attribute__ ((noinline,noclone)) get_input(void)
53   return 1;
56 static int __attribute__ ((noinline))
57 middleman (class A *obj, int i)
59   return obj->foo (i);
62 inline __attribute__ ((always_inline)) A::A()
64   if (middleman (this, get_input ()) != 2)
65     abort ();
68 static void bah ()
70   class B b;
73 int main (int argc, char *argv[])
75   int i;
77   for (i = 0; i < 10; i++)
78     bah ();
79   return 0;