xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/class.access/class.access.nest/p1.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // Derived from GNU's std::string
4*f4a2713aSLionel Sambuc namespace test0 {
5*f4a2713aSLionel Sambuc   class A {
6*f4a2713aSLionel Sambuc     struct B {
7*f4a2713aSLionel Sambuc       unsigned long length;
8*f4a2713aSLionel Sambuc     };
9*f4a2713aSLionel Sambuc     struct C : B {
10*f4a2713aSLionel Sambuc       static const unsigned long max_length;
11*f4a2713aSLionel Sambuc     };
12*f4a2713aSLionel Sambuc   };
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc   const unsigned long A::C::max_length = sizeof(B);
15*f4a2713aSLionel Sambuc }
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc // Example from the standard.
18*f4a2713aSLionel Sambuc namespace test1 {
19*f4a2713aSLionel Sambuc   class E {
20*f4a2713aSLionel Sambuc     int x;
21*f4a2713aSLionel Sambuc     class B {};
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc     class I {
24*f4a2713aSLionel Sambuc       B b;
25*f4a2713aSLionel Sambuc       int y; // expected-note {{declared private here}}
f(E * p,int i)26*f4a2713aSLionel Sambuc       void f(E* p, int i) {
27*f4a2713aSLionel Sambuc         p->x = i;
28*f4a2713aSLionel Sambuc       }
29*f4a2713aSLionel Sambuc     };
30*f4a2713aSLionel Sambuc 
g(I * p)31*f4a2713aSLionel Sambuc     int g(I* p) { return p->y; } // expected-error {{'y' is a private member of 'test1::E::I'}}
32*f4a2713aSLionel Sambuc   };
33*f4a2713aSLionel Sambuc }
34