Fix type in the changelog entry,
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-7.C
blobf27a264fd1e1fd76a810cfe9a484d913e338eb3b
1 /* Verify that IPA-CP can do devirtualization even if the virtual call
2    comes from a method that has been early-inlined into a descendant.  */
3 /* { dg-do run } */
4 /* { dg-options "-O3 -fdump-ipa-cp"  } */
5 /* { dg-add-options bind_pic_locally } */
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);
27   int middleman_1 (int i);
31 class B : public Distraction, public A
33 public:
34   virtual int foo (int i);
35   int middleman_2 (int i);
36   __attribute__ ((noinline)) B();
39 float Distraction::bar (float z)
41   f += z;
42   return f/2;
45 int A::foo (int i)
47   return i + 1;
50 int B::foo (int i)
52   return i + 2;
55 int __attribute__ ((noinline,noclone)) get_input(void)
57   return 1;
60 int inline __attribute__ ((always_inline))
61 A::middleman_1 (int i)
63   return this->foo (i);
66 int __attribute__ ((noinline))
67 B::middleman_2 (int i)
69   return this->middleman_1 (i);
72 B::B ()
76 int main (int argc, char *argv[])
78   class B b;
79   int i;
81   for (i = 0; i < get_input(); i++)
82     if (b.middleman_2 (get_input ()) != 3)
83       abort ();
84   return 0;
87 /* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*B::foo"  "cp"  } } */