summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/conversion/ptrmem6.C
blob: a3c0c966cefb30da1793c17300d5bb987e99c22c (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
26
27
28
29
30
31
32
33
34
35
// Copyright (C) 2007 Free Software Foundation
// Contributed by Ollie Wild <aaw@google.com>
// { dg-do compile }

// Assorted pointer to data member implicit cast tests.

struct A { int x; };
struct B : A { int x; };
struct P : A { int x; };
struct V { int x; };
struct D : B, virtual V, private P { int x; };

// Valid.
int D::*p1 = &B::x;

// Derived class.
int B::*p2 = &D::x; // { dg-error "" }

// Virtual base class.
int D::*p3 = &V::x; // { dg-error "" }

// Inaccessible base class.
int D::*p4 = &P::x; // { dg-error "" }

// Ambiguous base class.
int D::*p5 = &A::x;  // { dg-error "" }

// Increases cv-qualification.
const int D::*p6 = &B::x;

// Decreases cv-qualification.
int D::*p7 = static_cast<const int D::*>(&D::x); // { dg-error "" }

// Different member type.
float D::*p8 = &B::x;  // { dg-error "" }