Bug 29138 - [4.0 Regression] access declarations don't work for classes
Summary: [4.0 Regression] access declarations don't work for classes
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.1
: P1 normal
Target Milestone: 4.1.2
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2006-09-19 10:32 UTC by Andrew Stubbs
Modified: 2007-02-03 20:17 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 2.95.3 4.1.2 4.2.0
Known to fail: 3.0.4 4.0.0 4.1.0 3.2.3 3.4.0 3.3.3 4.1.1
Last reconfirmed: 2006-09-20 07:12:40


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Stubbs 2006-09-19 10:32:30 UTC
class A
{
public:
  int i;
  class A1
  {
    int j;
  };
};

class B : private A
{
public:
  A::i;
  A::A1;
};

void
f ()
{
  B b;
  b.i = 1;
  B::A1 a1;
}

The above program does not compile with the following messages:
t.cpp:15: error: declaration does not declare anything
t.cpp: In function ‘void f()’:
t.cpp:6: error: ‘class A::A1’ is inaccessible
t.cpp:23: error: within this context

The C++ standard section 11.3 talks about access declarators. It does not
explicitly say that inner classes can be used this way, but nor does it say
they cannot. Note that the integer `i' works fine with the same idiom.
Comment 1 Andrew Pinski 2006-09-20 07:12:40 UTC
Confirmed.
Comment 2 Mark Mitchell 2006-10-03 18:04:24 UTC
Subject: Bug 29138

Author: mmitchel
Date: Tue Oct  3 18:04:10 2006
New Revision: 117409

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117409
Log:
	PR c++/29138
	* decl2.c (grokfield): Don't handle access declarations here.
	* parser.c (cp_parser_using_declaration): Handle access
	declarations too.
	(cp_parser_block_declaration): Adjust calls to
	cp_parser_using_declaration.
	(cp_parser_member_declaration): Likewise.  Use
	cp_parser_using_declaration to look for access_declarations.
	PR c++/29138
	* g++.dg/inherit/access8.C: New test.
	* g++.dg/template/dtor4.C: Tweak error messages.

Added:
    trunk/gcc/testsuite/g++.dg/inherit/access8.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl2.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/dtor4.C

Comment 3 Mark Mitchell 2006-10-03 18:06:19 UTC
Subject: Bug 29138

Author: mmitchel
Date: Tue Oct  3 18:06:00 2006
New Revision: 117410

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117410
Log:
	PR c++/29138
	* decl2.c (grokfield): Don't handle access declarations here.
	* parser.c (cp_parser_using_declaration): Handle access
	declarations too.
	(cp_parser_block_declaration): Adjust calls to
	cp_parser_using_declaration.
	(cp_parser_member_declaration): Likewise.  Use
	cp_parser_using_declaration to look for access_declarations.
	PR c++/29138
	* g++.dg/inherit/access8.C: New test.
	* g++.dg/template/dtor4.C: Tweak error messages.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/inherit/access8.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/decl2.c
    branches/gcc-4_1-branch/gcc/cp/parser.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/dtor4.C

Comment 4 Mark Mitchell 2006-10-03 18:09:16 UTC
Fixed in 4.1.2, 4.2.0.
Comment 5 Mark Mitchell 2006-10-03 18:39:40 UTC
Subject: Bug 29138

Author: mmitchel
Date: Tue Oct  3 18:39:32 2006
New Revision: 117411

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117411
Log:
	PR c++/29138
	* decl2.c (grokfield): Don't handle access declarations here.
	* parser.c (cp_parser_using_declaration): Handle access
	declarations too.
	(cp_parser_block_declaration): Adjust calls to
	cp_parser_using_declaration.
	(cp_parser_member_declaration): Likewise.  Use
	cp_parser_using_declaration to look for access_declarations.
	PR c++/29138
	* g++.dg/inherit/access8.C: New test.
	* g++.dg/template/dtor4.C: Tweak error messages.

Modified:
    trunk/gcc/cp/parser.c

Comment 6 Gabriel Dos Reis 2007-02-03 20:17:21 UTC
Fixed in GCC-4.1.2.