summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/attr-ifunc-1.C
blob: d41fa7d3267c84d5ffa8143d0f0edf321bfcbde1 (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
/* { 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 main ()
{
  Klass obj;
  
  return obj.magic () != 0;
}