| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O3 -fno-early-inlining -fno-ipa-cp" } */ |
| 3 |
|
| 4 |
extern "C" void abort (void); |
| 5 |
|
| 6 |
class A |
| 7 |
{ |
| 8 |
public: |
| 9 |
virtual int foo (int i); |
| 10 |
}; |
| 11 |
|
| 12 |
class B |
| 13 |
{ |
| 14 |
public: |
| 15 |
class A confusion; |
| 16 |
}; |
| 17 |
|
| 18 |
int A::foo (int i) |
| 19 |
{ |
| 20 |
return i + 1; |
| 21 |
} |
| 22 |
|
| 23 |
int __attribute__ ((noinline,noclone)) get_input(void) |
| 24 |
{ |
| 25 |
return 1; |
| 26 |
} |
| 27 |
|
| 28 |
static int middleman_a (class A *obj, int i) |
| 29 |
{ |
| 30 |
return obj->foo (i); |
| 31 |
} |
| 32 |
|
| 33 |
static int middleman_b (class B *obj, int i) |
| 34 |
{ |
| 35 |
return middleman_a (&obj->confusion, i); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
int main (int argc, char *argv[]) |
| 40 |
{ |
| 41 |
class B b; |
| 42 |
int i, j = get_input (); |
| 43 |
|
| 44 |
for (i = 0; i < j; i++) |
| 45 |
if (middleman_b (&b, j) != 2) |
| 46 |
abort (); |
| 47 |
return 0; |
| 48 |
} |