Fix test-suite fallout of default -Wreturn-type.
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-d-1.C
blob3897a7782b3adaafd0f35007d8383eeff113ed02
1 /* Verify that ipa-cp correctly detects the dynamic type of an object
2    under destruction when doing devirtualization.  */
3 /* { dg-do run } */
4 /* { dg-options "-O3 -fno-early-inlining -fno-inline"  } */
6 extern "C" void abort (void);
8 class A
10 public:
11   int data;
12   ~A();
13   virtual int foo (int i);
16 class B : public A
18 public:
19   virtual int foo (int i);
22 class C : public A
24 public:
25   virtual int foo (int i);
28 int A::foo (int i)
30   return i + 1;
33 int B::foo (int i)
35   return i + 2;
38 int C::foo (int i)
40   return i + 3;
43 static int middleman (class A *obj, int i)
45   return obj->foo (i);
48 int __attribute__ ((noinline,noclone)) get_input(void)
50   return 1;
53 A::~A ()
55   if (middleman (this, get_input ()) != 2)
56     abort ();
59 static void bah ()
61   class B b;
64 int main (int argc, char *argv[])
66   int i;
68   for (i = 0; i < 10; i++)
69     bah ();
70   return 0;