| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-ifunc "" } */ |
| 3 |
/* { dg-options "-Wno-pmf-conversions" } */ |
| 4 |
|
| 5 |
#include <stdio.h> |
| 6 |
|
| 7 |
struct Klass |
| 8 |
{ |
| 9 |
virtual int magic () = 0; |
| 10 |
}; |
| 11 |
|
| 12 |
struct Klassier : Klass |
| 13 |
{ |
| 14 |
int implementation (); |
| 15 |
int magic (); |
| 16 |
|
| 17 |
typedef int Func (Klass*); |
| 18 |
|
| 19 |
static Func* resolver (); |
| 20 |
}; |
| 21 |
|
| 22 |
int Klassier::implementation (void) |
| 23 |
{ |
| 24 |
printf ("'ere I am JH\n"); |
| 25 |
return 0; |
| 26 |
} |
| 27 |
|
| 28 |
Klassier::Func* Klassier::resolver () |
| 29 |
{ |
| 30 |
/* GCC guarantees this conversion to be safe and the resulting pointer |
| 31 |
usable to call the member function using ordinary (i.e., non-member) |
| 32 |
function call syntax. */ |
| 33 |
|
| 34 |
return reinterpret_cast<Func*>(&Klassier::implementation); |
| 35 |
} |
| 36 |
|
| 37 |
int Klassier::magic (void) __attribute__ ((ifunc ("_ZN8Klassier8resolverEv"))); |
| 38 |
|
| 39 |
int __attribute__ ((weak)) Foo (Klass &base) |
| 40 |
{ |
| 41 |
return base.magic (); |
| 42 |
} |
| 43 |
|
| 44 |
int main () |
| 45 |
{ |
| 46 |
Klassier obj; |
| 47 |
|
| 48 |
return Foo (obj) != 0; |
| 49 |
} |