| 1 |
// { dg-lto-do run } |
| 2 |
// { dg-require-linker-plugin "" } |
| 3 |
// { dg-lto-options {{-O2 -fuse-linker-plugin -fno-early-inlining}} |
| 4 |
|
| 5 |
extern "C" void abort (void); |
| 6 |
extern "C" void linker_error (); |
| 7 |
|
| 8 |
class A |
| 9 |
{ |
| 10 |
public: |
| 11 |
int data; |
| 12 |
virtual int foo (int i) |
| 13 |
{ |
| 14 |
return i + 1; |
| 15 |
} |
| 16 |
}; |
| 17 |
|
| 18 |
class B : public A |
| 19 |
{ |
| 20 |
public: |
| 21 |
virtual int foo (int i) |
| 22 |
{ |
| 23 |
return i + 2; |
| 24 |
} |
| 25 |
}; |
| 26 |
|
| 27 |
class C : public A |
| 28 |
{ |
| 29 |
public: |
| 30 |
virtual int foo (int i) |
| 31 |
{ |
| 32 |
linker_error (); |
| 33 |
return i + 3; |
| 34 |
} |
| 35 |
}; |
| 36 |
|
| 37 |
|
| 38 |
static int middleman (class A *obj, int i) |
| 39 |
{ |
| 40 |
return obj->foo (i); |
| 41 |
} |
| 42 |
|
| 43 |
int __attribute__ ((noinline,noclone)) get_input(void) |
| 44 |
{ |
| 45 |
return 1; |
| 46 |
} |
| 47 |
|
| 48 |
int main (int argc, char *argv[]) |
| 49 |
{ |
| 50 |
class B b; |
| 51 |
if (middleman (&b, get_input ()) != 3) |
| 52 |
abort (); |
| 53 |
return 0; |
| 54 |
} |