// Copyright (C) 2007 Free Software Foundation
|
// Copyright (C) 2007 Free Software Foundation
|
// Contributed by Ollie Wild
|
// Contributed by Ollie Wild
|
// { dg-do compile }
|
// { dg-do compile }
|
|
|
// Assorted pointer to data member implicit cast tests.
|
// Assorted pointer to data member implicit cast tests.
|
|
|
struct A { int x; };
|
struct A { int x; };
|
struct B : A { int x; };
|
struct B : A { int x; };
|
struct P : A { int x; };
|
struct P : A { int x; };
|
struct V { int x; };
|
struct V { int x; };
|
struct D : B, virtual V, private P { int x; };
|
struct D : B, virtual V, private P { int x; };
|
|
|
// Valid.
|
// Valid.
|
int D::*p1 = &B::x;
|
int D::*p1 = &B::x;
|
|
|
// Derived class.
|
// Derived class.
|
int B::*p2 = &D::x; // { dg-error "" }
|
int B::*p2 = &D::x; // { dg-error "" }
|
|
|
// Virtual base class.
|
// Virtual base class.
|
int D::*p3 = &V::x; // { dg-error "" }
|
int D::*p3 = &V::x; // { dg-error "" }
|
|
|
// Inaccessible base class.
|
// Inaccessible base class.
|
int D::*p4 = &P::x; // { dg-error "" }
|
int D::*p4 = &P::x; // { dg-error "" }
|
|
|
// Ambiguous base class.
|
// Ambiguous base class.
|
int D::*p5 = &A::x; // { dg-error "" }
|
int D::*p5 = &A::x; // { dg-error "" }
|
|
|
// Increases cv-qualification.
|
// Increases cv-qualification.
|
const int D::*p6 = &B::x;
|
const int D::*p6 = &B::x;
|
|
|
// Decreases cv-qualification.
|
// Decreases cv-qualification.
|
int D::*p7 = static_cast(&D::x); // { dg-error "" }
|
int D::*p7 = static_cast(&D::x); // { dg-error "" }
|
|
|
// Different member type.
|
// Different member type.
|
float D::*p8 = &B::x; // { dg-error "" }
|
float D::*p8 = &B::x; // { dg-error "" }
|
|
|