Fix type in the changelog entry,
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-c-5.C
blob637d7d4be1bc8aa3b7731f984ce71f3114831cbb
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-early-inlining -fno-inline"  } */
6 extern "C" void abort (void);
8 class B;
10 class A
12 public:
13   int data;
14   A();
15   A(B *b);
16   virtual int foo (int i);
19 class B : public A
21 public:
22   virtual int foo (int i);
25 class C : public A
27 public:
28   virtual int foo (int i);
31 int A::foo (int i)
33   return i + 1;
36 int B::foo (int i)
38   return i + 2;
41 int C::foo (int i)
43   return i + 3;
46 static int middleman (class A *obj, int i)
48   return obj->foo (i);
51 int __attribute__ ((noinline,noclone)) get_input(void)
53   return 1;
56 A::A ()
60 A::A (B *b)
62   if (middleman (b, get_input ()) != 3)
63     abort ();
66 static void bah ()
68   B b;
69   A a(&b);
72 int main (int argc, char *argv[])
74   int i;
76   for (i = 0; i < 10; i++)
77     bah ();
78   return 0;