Fix type in the changelog entry,
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / pr60640-4.C
blobfd7a6c129990ede084d60472095abadf9185546e
1 // { dg-do run }
2 // { dg-options "-O3 -fdump-ipa-cp" }
4 struct Distraction
6   char fc[8];
7   virtual Distraction * return_self ()
8   { return this; }
9 };
11 namespace {
13 struct A;
14 static A * __attribute__ ((noinline, noclone)) get_an_A ();
16 static int go;
18 struct A
20   int fi;
22   A () : fi(777) {}
23   A (int pi) : fi (pi) {}
24   virtual void foo (int p) = 0;
27 struct B : public Distraction, A
29   B () : Distraction(), A() { }
30   B (int pi) : Distraction (), A (pi) {}
31   virtual void foo (int p)
32   {
33     int o = fi;
34     for (int i = 0; i < p; i++)
35       o += i + i * i;
36     go = o;
37   }
41 struct B gb (2);
42 static A * __attribute__ ((noinline, noclone))
43 get_an_A ()
45   return &gb;
50 static int __attribute__ ((noinline, noclone))
51 get_a_number ()
53   return 5;
56 extern "C" void abort (void);
58 static void __attribute__ ((noinline, noclone))
59 bar ()
61   for (int i = 0; i < get_a_number (); i++)
62     {
63       struct A *p = get_an_A ();
64       p->foo (4);
65       if (go != 22)
66         abort ();
67     }
70 int main (int argc, char *argv[])
72   for (int i = 0; i < get_a_number (); i++)
73     {
74       struct A *p = get_an_A ();
75       p->foo (4);
76       if (go != 22)
77         abort ();
78     }
80   bar ();
81   return 0;
84 /* { dg-final { scan-ipa-dump-times "Thunk fixed offset" 2 "cp"} } */