From 2d63754709c889b1087e692b6124e0ed9fc00a8b Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 27 May 2005 14:23:47 +0000 Subject: re PR c++/21681 (ICE with nested types in template) cp: PR c++/21681 * parser.c (cp_parser_late_parsing_for_member): Disable access checking for template functions. testsuite: PR c++/21681 * g++.dg/parse/template16.C: New. From-SVN: r100252 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 8 ++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/template16.C | 15 +++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/g++.dg/parse/template16.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1fde495..6f29005 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-05-27 Nathan Sidwell + + PR c++/21681 + * parser.c (cp_parser_late_parsing_for_member): Disable access + checking for template functions. + 2005-05-26 Volker Reichelt PR c++/21768 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a0d71b3..7f39c91 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15486,6 +15486,7 @@ cp_parser_late_parsing_for_member (cp_parser* parser, tree member_function) 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); @@ -15494,10 +15495,17 @@ cp_parser_late_parsing_for_member (cp_parser* parser, tree member_function) 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a114bdb..c424bf5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-05-27 Nathan Sidwell + + PR c++/21681 + * g++.dg/parse/template16.C: New. + 2005-05-27 Andreas Jaeger * gcc.dg/setjmp-2.c: Only run in 32-bit. diff --git a/gcc/testsuite/g++.dg/parse/template16.C b/gcc/testsuite/g++.dg/parse/template16.C new file mode 100644 index 0000000..bc41b0f --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/template16.C @@ -0,0 +1,15 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 May 2005 + +// Origin:Volker Reichelt reichelt@gcc.gnu.org +// PR 21681. ICE with inappropriate access check. + +template struct A; + +struct B +{ + template void foo() + { + A::X::Y; + } +}; -- cgit v1.1