Bug 24782 - [3.4/4.0/4.1/4.2 Regression] wrongly accepted nested private typedef
Summary: [3.4/4.0/4.1/4.2 Regression] wrongly accepted nested private typedef
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P2 minor
Target Milestone: 4.0.3
Assignee: Mark Mitchell
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2005-11-10 20:27 UTC by Wouter Vermaelen
Modified: 2006-01-04 18:53 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.3
Known to fail: 3.4.0 4.0.0 4.1.0
Last reconfirmed: 2005-11-10 20:31:31


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wouter Vermaelen 2005-11-10 20:27:54 UTC
class Foo { public:  typedef int type1; };
class Bar { private: typedef Foo type2; };
void f(Bar::type2       ) {} // rejected, OK
void g(Bar::type2::type1) {} // accepted ???

gcc-3.2.3 and 3.3.6 reject both lines
3.4.5  4.0.3 and CVS snapshot wrongly(?) accept the last line
Comment 1 Andrew Pinski 2005-11-10 20:31:31 UTC
Confirmed.
Comment 2 Mark Mitchell 2005-11-19 02:09:09 UTC
It would be nice to fix this, but not critical.
Comment 3 Mark Mitchell 2006-01-04 04:24:00 UTC
The problem is as follows:

(1) cp_parser_nested_name_specifier_opt defers accessing checking.

(2) In the case that it is parsing tentatively, it creates a CPP_NESTED_NAME_SPECIFIER token, recording the access checks therein.

(3) However, if the tentative parse succeeds, nothing ever goes back to check those checks.

The saved checks should also be re-deferred, after the call to pop_deferring_access_checks, perhaps via pop_to_parent_deferring_access_checks.
Comment 4 Mark Mitchell 2006-01-04 18:48:43 UTC
Subject: Bug 24782

Author: mmitchel
Date: Wed Jan  4 18:48:38 2006
New Revision: 109342

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109342
Log:
	PR c++/24782
	* parser.c (cp_parser_nested_name_specifier_opt): Preserve access
	checks, even when parsing tentatively.
	PR c++/24782
	* g++.dg/parse/access9.C: New test.
	* g++.dg/tc1/dr52.C: Tweak error markers.

Added:
    trunk/gcc/testsuite/g++.dg/parse/access9.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/tc1/dr52.C

Comment 5 Mark Mitchell 2006-01-04 18:49:26 UTC
Subject: Bug 24782

Author: mmitchel
Date: Wed Jan  4 18:49:21 2006
New Revision: 109343

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109343
Log:
	PR c++/24782
	* parser.c (cp_parser_nested_name_specifier_opt): Preserve access
	checks, even when parsing tentatively.
	PR c++/24782
	* g++.dg/parse/access9.C: New test.
	* g++.dg/tc1/dr52.C: Tweak error markers.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/parse/access9.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    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/tc1/dr52.C

Comment 6 Mark Mitchell 2006-01-04 18:50:10 UTC
Subject: Bug 24782

Author: mmitchel
Date: Wed Jan  4 18:50:07 2006
New Revision: 109344

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109344
Log:
	PR c++/24782
	* parser.c (cp_parser_nested_name_specifier_opt): Preserve access
	checks, even when parsing tentatively.
	PR c++/24782
	* g++.dg/parse/access9.C: New test.
	* g++.dg/tc1/dr52.C: Tweak error markers.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/parse/access9.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/parser.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/tc1/dr52.C

Comment 7 Mark Mitchell 2006-01-04 18:53:35 UTC
Fixed in 4.0.3.