Debian Codegraph @

gcc/testsuite/g++.dg/ext/attr-ifunc-2.C

raw
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 int implementation ();
10 int magic ();
11
12 typedef int Func (Klass*);
13
14 static Func* resolver ();
15 };
16
17 int Klass::implementation (void)
18 {
19 printf ("'ere I am JH\n");
20 return 0;
21 }
22
23 Klass::Func* Klass::resolver (void)
24 {
25 /* GCC guarantees this conversion to be safe and the resulting pointer
26 usable to call the member function using ordinary (i.e., non-member)
27 function call syntax. */
28
29 return reinterpret_cast<Func*>(&Klass::implementation);
30 }
31
32 int Klass::magic (void) __attribute__ ((ifunc ("_ZN5Klass8resolverEv")));
33
34 struct Klassier : Klass
35 {
36 };
37
38 int main ()
39 {
40 Klassier obj;
41
42 return obj.magic () != 0;
43 }