1 // RUN: %clang_cc1 -verify %s
19 private: static int x
; // expected-note 5 {{declared private here}}
20 static int test() { return x
; }
23 static int test() { return x
; } // expected-error {{private member}}
25 struct C
: private A
{
26 static int test() { return x
; } // expected-error {{private member}}
30 public: static int x
; // expected-note{{member is declared here}}
31 static int test() { return x
; }
33 struct E
: private D
{ // expected-note{{constrained by private inheritance}}
34 static int test() { return x
; }
38 return A::x
// expected-error {{private member}}
39 + B::x
// expected-error {{private member}}
40 + C::x
// expected-error {{private member}}
42 + E::x
; // expected-error {{private member}}
48 protected: static int x
; // expected-note{{member is declared here}}
51 class B
: private A
{}; // expected-note {{private inheritance}}
54 return b
->x
; // expected-error {{private member}}
61 protected: static int x
;
64 class B
: public A
{};
67 // x is accessible at C when named in A.
68 // A is an accessible base of B at C.
69 // Therefore this succeeds.
75 // Don't crash. <rdar://12926092>
76 // Note that 'field' is indeed a private member of X but that access
77 // is indeed ultimately constrained by the protected inheritance from Y.
78 // If someone wants to put the effort into improving this diagnostic,
79 // they can feel free; even explaining it in person would be a pain.
87 int field
; // expected-note {{member is declared here}}
90 class Y
: public X
{ };
91 class Z
: protected Y
{ }; // expected-note {{constrained by protected inheritance here}}
94 p
->field
= 0; // expected-error {{'field' is a private member of 'test4::X'}}
98 // TODO: flesh out these cases