Commit 7f1ba716 by Mark Mitchell Committed by Mark Mitchell

re PR c++/29729 (ICE with template class in template function)

	PR c++/29729
	* decl2.c (check_member_template): Move check for member
	templates in local classes to ...
	* parser.c (cp_parser_template_declaration_after_export):
	... here.
	PR c++/29729
	* g++.dg/template/crash63.C: New test.

From-SVN: r119575
parent f75709c6
2006-12-05 Mark Mitchell <mark@codesourcery.com> 2006-12-05 Mark Mitchell <mark@codesourcery.com>
PR c++/29729
* decl2.c (check_member_template): Move check for member
templates in local classes to ...
* parser.c (cp_parser_template_declaration_after_export):
... here.
PR c++/29728 PR c++/29728
* decl.c (check_array_designated_initializer): New function. * decl.c (check_array_designated_initializer): New function.
(maybe_deduce_size_from_array_init): Use it. (maybe_deduce_size_from_array_init): Use it.
......
...@@ -445,13 +445,8 @@ check_member_template (tree tmpl) ...@@ -445,13 +445,8 @@ check_member_template (tree tmpl)
|| (TREE_CODE (decl) == TYPE_DECL || (TREE_CODE (decl) == TYPE_DECL
&& IS_AGGR_TYPE (TREE_TYPE (decl)))) && IS_AGGR_TYPE (TREE_TYPE (decl))))
{ {
if (current_function_decl) /* The parser rejects template declarations in local classes. */
/* 14.5.2.2 [temp.mem] gcc_assert (!current_function_decl);
A local class shall not have member templates. */
error ("invalid declaration of member template %q#D in local class",
decl);
/* The parser rejects any use of virtual in a function template. */ /* The parser rejects any use of virtual in a function template. */
gcc_assert (!(TREE_CODE (decl) == FUNCTION_DECL gcc_assert (!(TREE_CODE (decl) == FUNCTION_DECL
&& DECL_VIRTUAL_P (decl))); && DECL_VIRTUAL_P (decl)));
......
...@@ -15696,6 +15696,15 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) ...@@ -15696,6 +15696,15 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p)
/* And the `<'. */ /* And the `<'. */
if (!cp_parser_require (parser, CPP_LESS, "`<'")) if (!cp_parser_require (parser, CPP_LESS, "`<'"))
return; return;
if (at_class_scope_p () && current_function_decl)
{
/* 14.5.2.2 [temp.mem]
A local class shall not have member templates. */
error ("invalid declaration of member template in local class");
cp_parser_skip_to_end_of_block_or_statement (parser);
return;
}
/* [temp] /* [temp]
A template ... shall not have C linkage. */ A template ... shall not have C linkage. */
......
2006-12-05 Mark Mitchell <mark@codesourcery.com> 2006-12-05 Mark Mitchell <mark@codesourcery.com>
PR c++/29729
* g++.dg/template/crash63.C: New test.
PR c++/29728 PR c++/29728
* g++.dg/template/crash62.C: New test. * g++.dg/template/crash62.C: New test.
// PR c++/29729
template<typename T> void foo(T)
{
struct A
{
template<int> struct B // { dg-error "local class" }
{
typedef B<0> C;
}
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment