This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix 21681
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 27 May 2005 15:08:04 +0100
- Subject: [C++ PATCH] Fix 21681
Hi,
I've installed this patch to fix 21681 -- we should never be doing access checks
when parsing a template.
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
2005-05-27 Nathan Sidwell <nathan@codesourcery.com>
PR c++/21681
* parser.c (cp_parser_late_parsing_for_member): Disable access
checking for template functions.
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.330
diff -c -3 -p -r1.330 parser.c
*** cp/parser.c 17 May 2005 20:05:13 -0000 1.330
--- cp/parser.c 27 May 2005 13:51:18 -0000
*************** cp_parser_late_parsing_for_member (cp_pa
*** 15484,15489 ****
--- 15484,15490 ----
if (function_scope)
push_function_context_to (function_scope);
+
/* Push the body of the function onto the lexer stack. */
cp_parser_push_lexer_for_tokens (parser, tokens);
*************** cp_parser_late_parsing_for_member (cp_pa
*** 15492,15501 ****
--- 15493,15509 ----
start_preparsed_function (member_function, NULL_TREE,
SF_PRE_PARSED | SF_INCLASS_INLINE);
+ /* Don't do access checking if it is a templated function. */
+ if (processing_template_decl)
+ push_deferring_access_checks (dk_no_check);
+
/* Now, parse the body of the function. */
cp_parser_function_definition_after_declarator (parser,
/*inline_p=*/true);
+ if (processing_template_decl)
+ pop_deferring_access_checks ();
+
/* Leave the scope of the containing function. */
if (function_scope)
pop_function_context_from (function_scope);
// Copyright (C) 2005 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 May 2005 <nathan@codesourcery.com>
// Origin:Volker Reichelt reichelt@gcc.gnu.org
// PR 21681. ICE with inappropriate access check.
template<int X> struct A;
struct B
{
template<int N> void foo()
{
A<N>::X::Y;
}
};