| 1 |
// Copyright (C) 2004 Free Software Foundation, Inc. |
| 2 |
// Contributed by Nathan Sidwell 20 Oct 2004 <[email protected]> |
| 3 |
|
| 4 |
// DR 195 was about allowing conversions between function and object |
| 5 |
// pointers under some circumstances. The issue got resolved for C++11, |
| 6 |
// which, in 5.2.10 p8 says that: "Converting a function pointer to an |
| 7 |
// object pointer type or vice versa is conditionally-supported." |
| 8 |
|
| 9 |
// This checks we don't warn anymore with -pedantic. |
| 10 |
|
| 11 |
typedef void (*PF)(void); |
| 12 |
typedef void *PV; |
| 13 |
typedef int *PO; |
| 14 |
|
| 15 |
void foo () |
| 16 |
{ |
| 17 |
PF pf; |
| 18 |
PV pv; |
| 19 |
PO po; |
| 20 |
|
| 21 |
/* the following two will almost definitly be ok with 195. */ |
| 22 |
pf = reinterpret_cast <PF>(pv); |
| 23 |
pv = reinterpret_cast <PV>(pf); |
| 24 |
|
| 25 |
/* the following two might or might not be ok with 195. */ |
| 26 |
pf = reinterpret_cast <PF>(po); |
| 27 |
po = reinterpret_cast <PO>(pf); |
| 28 |
|
| 29 |
/* These will never be ok, as they are implicit. */ |
| 30 |
pv = pf; // { dg-error "invalid conversion" } |
| 31 |
pf = pv; // { dg-error "invalid conversion" } |
| 32 |
} |