view gcc/testsuite/g++.dg/conversion/ptrmem6.C @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 04ced10e8804
children
line wrap: on
line source

// 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 "" }