1 // RUN: %clang_cc1 -fsyntax-only -verify %s
7 int (Base::*data_ptr
) = &Base::data
;
8 int (Base::*method_ptr
)() = &Base::method
;
11 struct Derived
: Base
{};
13 int (Derived::*d
) = data_ptr
;
14 int (Derived::*m
)() = method_ptr
;
18 // Can't be inaccessible.
20 struct Derived
: private Base
{}; // expected-note 2 {{declared private here}}
22 int (Derived::*d
) = data_ptr
; // expected-error {{cannot cast private base class 'Base' to 'test1::Derived'}}
23 int (Derived::*m
)() = method_ptr
; // expected-error {{cannot cast private base class 'Base' to 'test1::Derived'}}
27 // Can't be ambiguous.
31 struct Derived
: A
, B
{};
33 int (Derived::*d
) = data_ptr
; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test2::Derived':}}
34 int (Derived::*m
)() = method_ptr
; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test2::Derived':}}
40 struct Derived
: virtual Base
{};
42 int (Derived::*d
) = data_ptr
; // expected-error {{conversion from pointer to member of class 'Base' to pointer to member of class 'test3::Derived' via virtual base 'Base' is not allowed}}
43 int (Derived::*m
)() = method_ptr
; // expected-error {{conversion from pointer to member of class 'Base' to pointer to member of class 'test3::Derived' via virtual base 'Base' is not allowed}}
47 // Can't be virtual even if there's a non-virtual path.
50 struct Derived
: Base
, virtual A
{}; // expected-warning {{direct base 'Base' is inaccessible due to ambiguity:\n struct test4::Derived -> Base\n struct test4::Derived -> A -> Base}}
52 int (Derived::*d
) = data_ptr
; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test4::Derived':}}
53 int (Derived::*m
)() = method_ptr
; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test4::Derived':}}
57 // PR6254: don't get thrown off by a virtual base.
60 struct Derived
: Base
, virtual A
{};
62 int (Derived::*d
) = data_ptr
;
63 int (Derived::*m
)() = method_ptr
;