This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Fix 16260
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 29 Jun 2004 12:06:17 +0100
- Subject: [C++ PATCH]: Fix 16260
- Organization: CodeSourcery LLC
Hi,
I've installed this obvious fix for something I recently broke. Disabling
access at this point is the correct thing -- we don't go through this
point for specializations.
built & tested on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2004-06-29 Nathan Sidwell <nathan@codesourcery.com>
PR c++/16260
* parser.c (cp_parser_template_declaration_after_export): Disable
access checks here ...
(cp_parser_class_specifier): ... not here.
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.221
diff -c -3 -p -r1.221 parser.c
*** cp/parser.c 28 Jun 2004 10:41:13 -0000 1.221
--- cp/parser.c 29 Jun 2004 11:00:50 -0000
*************** cp_parser_class_specifier (cp_parser* pa
*** 12343,12353 ****
pop_p = push_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (type)));
type = begin_class_definition (type);
- if (processing_template_decl)
- /* There are no access checks when parsing a template, as we do no
- know if a specialization will be a friend. */
- push_deferring_access_checks (dk_no_check);
-
if (type == error_mark_node)
/* If the type is erroneous, skip the entire body of the class. */
cp_parser_skip_to_closing_brace (parser);
--- 12343,12348 ----
*************** cp_parser_class_specifier (cp_parser* pa
*** 12355,12363 ****
/* Parse the member-specification. */
cp_parser_member_specification_opt (parser);
- if (processing_template_decl)
- pop_deferring_access_checks ();
-
/* Look for the trailing `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "`}'");
/* We get better error messages by noticing a common problem: a
--- 12350,12355 ----
*************** cp_parser_template_declaration_after_exp
*** 14879,14888 ****
--- 14871,14886 ----
cp_parser_template_declaration_after_export (parser, member_p);
else
{
+ /* There are no access checks when parsing a template, as we do not
+ know if a specialization will be a friend. */
+ push_deferring_access_checks (dk_no_check);
+
decl = cp_parser_single_declaration (parser,
member_p,
&friend_p);
+ pop_deferring_access_checks ();
+
/* If this is a member template declaration, let the front
end know. */
if (member_p && !friend_p && decl)
// { dg-do compile }
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 29 Jun 2004 <nathan@codesourcery.com>
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
// Bug 16260. ICE
template<typename T> int foo() { return T::X::Y; }