diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/other/access2.C')
-rw-r--r-- | gcc/testsuite/g++.dg/other/access2.C | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/other/access2.C b/gcc/testsuite/g++.dg/other/access2.C new file mode 100644 index 000000000..c7dd77a04 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/access2.C @@ -0,0 +1,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(); +} |