re PR c++/2739 (g++ allows accessing private members)
PR c++/2739 * g++.dg/other/access2.C: New test. From-SVN: r60605
This commit is contained in:
parent
348d992107
commit
f2551f3571
@ -1,3 +1,8 @@
|
||||
2002-12-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
PR c++/2739
|
||||
* g++.dg/other/access2.C: New test.
|
||||
|
||||
2002-12-29 Gabriel Dos Reis <gdr@integrable-solutions.net>
|
||||
|
||||
* g++.dg/other/anon-struct.C: No longer fails
|
||||
|
35
gcc/testsuite/g++.dg/other/access2.C
Normal file
35
gcc/testsuite/g++.dg/other/access2.C
Normal file
@ -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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user