aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/warn/Wconditionally-supported-1.C
blob: 8cc5966eda823e628f339aec93c0cb04f9e16ed2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// { dg-options "-Wconditionally-supported" }

// DR 195 was about allowing conversions between function and object
// pointers under some circumstances.  The issue got resolved for C++11,
// which, in 5.2.10 p8 says that: "Converting a function pointer to an 
// object pointer type or vice versa is conditionally-supported."

// This checks we warn with -Wconditionally-supported.

typedef void (*PF)(void);
typedef void *PV;
typedef int *PO;

void foo ()
{
  PF pf;
  PV pv;
  PO po;

  pf = reinterpret_cast <PF>(pv); // { dg-warning "conditionally-supported" }
  pv = reinterpret_cast <PV>(pf); // { dg-warning "conditionally-supported" }

  pf = reinterpret_cast <PF>(po); // { dg-warning "conditionally-supported" }
  po = reinterpret_cast <PO>(pf); // { dg-warning "conditionally-supported" }
}