summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/other/access2.C
blob: c7dd77a043aefb7d51c898a3a2fd2cc49fb78757 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// { dg-do compile }
// Origin: Dirk Mueller <dmuell@gmx.net>

// PR c++/2739
// Access to base class private static member.

class Base {
private:
  static int fooprivate;
protected:
  static int fooprotected;
public:
  static int foopublic;
};

class Derived : public Base {
public:
  void test();
};

int Base::fooprivate=42;	// { dg-error "private" }
int Base::fooprotected=42;
int Base::foopublic=42;

void Derived::test() {
  if ( fooprivate );		// { dg-error "context" }
  if ( fooprotected );
  if ( foopublic );
}

int main()
{
  Derived d;
  d.test();
}