summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/attr-ifunc-3.C
blob: ba65976b96495ada26562c7fb2ecceef713fca10 (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
/* { dg-do run }  */
/* { dg-require-ifunc "" } */
/* { dg-options "-Wno-pmf-conversions" } */

#include <stdio.h>

struct Klass
{
  int implementation ();
  int magic ();
  static void *resolver ();
};

int Klass::implementation (void)
{
  printf ("'ere I am JH\n");
  return 0;
}

void *Klass::resolver (void)
{
  int (Klass::*pmf) () = &Klass::implementation;
  
  return (void *)(int (*)(Klass *))(((Klass *)0)->*pmf);
}

int Klass::magic (void) __attribute__ ((ifunc ("_ZN5Klass8resolverEv")));

int Foo (Klass &obj, int (Klass::*pmf) ())
{
  return (obj.*pmf) ();
}

int main ()
{
  Klass obj;
  
  return Foo (obj, &Klass::magic) != 0;
}