| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O3 -fno-early-inlining" } */ |
| 3 |
|
| 4 |
class H |
| 5 |
{ |
| 6 |
public: |
| 7 |
virtual unsigned bar() const { return 16; } |
| 8 |
}; |
| 9 |
|
| 10 |
class A : public H |
| 11 |
{ |
| 12 |
unsigned foo(unsigned (H::*func)(void) const) const; |
| 13 |
public: |
| 14 |
H *h; |
| 15 |
virtual unsigned bar() const; |
| 16 |
}; |
| 17 |
|
| 18 |
unsigned A::foo(unsigned (H::*func)(void) const) const |
| 19 |
{ |
| 20 |
return (h->*func)(); |
| 21 |
} |
| 22 |
|
| 23 |
unsigned A::bar() const |
| 24 |
{ |
| 25 |
return foo(&H::bar); |
| 26 |
} |
| 27 |
|
| 28 |
int main (int argc, char **argv) |
| 29 |
{ |
| 30 |
H h; |
| 31 |
A a; |
| 32 |
a.h = &h; |
| 33 |
|
| 34 |
if (a.bar() != 16) |
| 35 |
__builtin_abort (); |
| 36 |
return 0; |
| 37 |
} |