| 1 |
// Copyright (C) 2007 Free Software Foundation |
| 2 |
// Contributed by Ollie Wild <[email protected]> |
| 3 |
// { dg-do compile } |
| 4 |
|
| 5 |
// Assorted pointer to data member implicit cast tests. |
| 6 |
|
| 7 |
struct A { int x; }; |
| 8 |
struct B : A { int x; }; |
| 9 |
struct P : A { int x; }; |
| 10 |
struct V { int x; }; |
| 11 |
struct D : B, virtual V, private P { int x; }; |
| 12 |
|
| 13 |
// Valid. |
| 14 |
int D::*p1 = &B::x; |
| 15 |
|
| 16 |
// Derived class. |
| 17 |
int B::*p2 = &D::x; // { dg-error "" } |
| 18 |
|
| 19 |
// Virtual base class. |
| 20 |
int D::*p3 = &V::x; // { dg-error "" } |
| 21 |
|
| 22 |
// Inaccessible base class. |
| 23 |
int D::*p4 = &P::x; // { dg-error "" } |
| 24 |
|
| 25 |
// Ambiguous base class. |
| 26 |
int D::*p5 = &A::x; // { dg-error "" } |
| 27 |
|
| 28 |
// Increases cv-qualification. |
| 29 |
const int D::*p6 = &B::x; |
| 30 |
|
| 31 |
// Decreases cv-qualification. |
| 32 |
int D::*p7 = static_cast<const int D::*>(&D::x); // { dg-error "" } |
| 33 |
|
| 34 |
// Different member type. |
| 35 |
float D::*p8 = &B::x; // { dg-error "" } |