Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/ext/attr-ifunc-4.C @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
/* { dg-do run } */ /* { dg-require-ifunc "" } */ /* { dg-options "-Wno-pmf-conversions" } */ #include <stdio.h> struct Klass { virtual int magic () = 0; }; struct Klassier : Klass { int implementation (); int magic (); typedef int Func (Klass*); static Func* resolver (); }; int Klassier::implementation (void) { printf ("'ere I am JH\n"); return 0; } Klassier::Func* Klassier::resolver () { /* GCC guarantees this conversion to be safe and the resulting pointer usable to call the member function using ordinary (i.e., non-member) function call syntax. */ return reinterpret_cast<Func*>(&Klassier::implementation); } int Klassier::magic (void) __attribute__ ((ifunc ("_ZN8Klassier8resolverEv"))); int __attribute__ ((weak)) Foo (Klass &base) { return base.magic (); } int main () { Klassier obj; return Foo (obj) != 0; }