summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ipa/remref-2.C
blob: 1cece6541c97e722e2b98b0cba8855f826c4c577 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Verify that we survive creation and deletion of references to facilitate
   reference removal while also doing (unsuccessful) speculative
   devirtualization.  */
/* { dg-do link } */
/* { dg-options "-O3 -fno-early-inlining"  } */

class A
{
  public:
  virtual void __attribute__ ((noinline)) foo(void (*)(void));
};

static
void b(void)
{
}

void  __attribute__ ((noinline))
A::foo(void (*back)(void))
{
  back();
}

class A *a;

void __attribute__ ((noinline, noclone))
allocate_a ()
{
  a = new A();
}

int main()
{
  allocate_a();
  for (int i=0; i<10000;i++)
    a->foo(b);
}