OSDN Git Service

2012-12-15 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / conversion / ptrmem5.C
1 // Copyright (C) 2007 Free Software Foundation
2 // Contributed by Ollie Wild <aaw@google.com>
3 // { dg-do compile }
4
5 // Assorted pointer to member function c-style cast tests.
6
7 struct X {};
8 struct A { int f (); };
9 struct B : A { int f (); };
10 struct P : A { int f (); };
11 struct V { int f (); };
12 struct D : B, virtual V, private P { int f (); };
13
14 // Accessible, non-virtual, non-ambiguous base clas.
15 int (B::*p1)() = (int (B::*)())&D::f;
16 int (D::*p2)() = (int (D::*)())&B::f;
17
18 // Virtual base class.
19 int (V::*p3)() = (int (V::*)())&D::f;  // { dg-error "" }
20 int (D::*p4)() = (int (D::*)())&V::f;  // { dg-error "" }
21
22 // Inaccessible base class.
23 int (P::*p5)() = (int (P::*)())&D::f;
24 int (D::*p6)() = (int (D::*)())&P::f;
25
26 // Ambiguous base class.
27 int (A::*p7)() = (int (A::*)())&D::f;  // { dg-error "" }
28 int (D::*p8)() = (int (D::*)())&A::f;  // { dg-error "" }
29
30 // Attempts to change member type allowed via reinterpret_cast.
31 float (B::*p13)() = (float (B::*)())&D::f;
32 float (D::*p14)() = (float (D::*)())&B::f;
33
34 // Conversion via unrelated classes allwed via reinterpret_cast.
35 int (X::*p15)() = (int (X::*)())&D::f;