Debian Codegraph @

gcc/testsuite/g++.dg/other/access2.C

raw
1 // { dg-do compile }
2 // Origin: Dirk Mueller <[email protected]>
3
4 // PR c++/2739
5 // Access to base class private static member.
6
7 class Base {
8 private:
9 static int fooprivate;
10 protected:
11 static int fooprotected;
12 public:
13 static int foopublic;
14 };
15
16 class Derived : public Base {
17 public:
18 void test();
19 };
20
21 int Base::fooprivate=42; // { dg-message "private" }
22 int Base::fooprotected=42;
23 int Base::foopublic=42;
24
25 void Derived::test() {
26 if ( fooprivate ); // { dg-error "context" }
27 if ( fooprotected );
28 if ( foopublic );
29 }
30
31 int main()
32 {
33 Derived d;
34 d.test();
35 }