summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ipa/pr45875.C
blob: 34f02e300a2e87e8daa0fa2c04fe57c5eff7336a (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
38
39
40
41
42
43
44
45
46
47
48
/* { dg-do compile } */
/* { dg-options "-O3 -fno-early-inlining -fno-ipa-cp"  } */

extern "C" void abort (void);

class A
{
public:
  virtual int foo (int i);
};

class B
{
public:
  class A confusion;
};

int A::foo (int i)
{
  return i + 1;
}

int __attribute__ ((noinline,noclone)) get_input(void)
{
  return 1;
}

static int middleman_a (class A *obj, int i)
{
  return obj->foo (i);
}

static int middleman_b (class B *obj, int i)
{
  return middleman_a (&obj->confusion, i);
}


int main (int argc, char *argv[])
{
  class B b;
  int i, j = get_input ();

  for (i = 0; i < j; i++)
    if (middleman_b (&b, j) != 2)
      abort ();
  return 0;
}