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
Confirmed.
It would be nice to fix this, but not critical.
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.
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
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
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
Fixed in 4.0.3.