| 1 |
// { dg-options "-Wconditionally-supported" } |
| 2 |
|
| 3 |
// DR 195 was about allowing conversions between function and object |
| 4 |
// pointers under some circumstances. The issue got resolved for C++11, |
| 5 |
// which, in 5.2.10 p8 says that: "Converting a function pointer to an |
| 6 |
// object pointer type or vice versa is conditionally-supported." |
| 7 |
|
| 8 |
// This checks we warn with -Wconditionally-supported. |
| 9 |
|
| 10 |
typedef void (*PF)(void); |
| 11 |
typedef void *PV; |
| 12 |
typedef int *PO; |
| 13 |
|
| 14 |
void foo () |
| 15 |
{ |
| 16 |
PF pf; |
| 17 |
PV pv; |
| 18 |
PO po; |
| 19 |
|
| 20 |
pf = reinterpret_cast <PF>(pv); // { dg-warning "8:casting between pointer-to-function and pointer-to-object is conditionally-supported" } |
| 21 |
pv = reinterpret_cast <PV>(pf); // { dg-warning "8:casting between pointer-to-function and pointer-to-object is conditionally-supported" } |
| 22 |
|
| 23 |
pf = reinterpret_cast <PF>(po); // { dg-warning "8:casting between pointer-to-function and pointer-to-object is conditionally-supported" } |
| 24 |
po = reinterpret_cast <PO>(pf); // { dg-warning "8:casting between pointer-to-function and pointer-to-object is conditionally-supported" } |
| 25 |
|
| 26 |
pf = __extension__ reinterpret_cast <PF>(pv); |
| 27 |
pv = __extension__ reinterpret_cast <PV>(pf); |
| 28 |
|
| 29 |
pf = __extension__ reinterpret_cast <PF>(po); |
| 30 |
po = __extension__ reinterpret_cast <PO>(pf); |
| 31 |
} |