re PR c++/12403 (ICE in push_template_decl_real on member function template specialization)

PR c++/12403
	* parser.c (cp_parser_template_declaration_after_export): Set up
	template specialization scope in case of explicit specialization.

	* g++.dg/parse/explicit1.C: New test.
	* g++.old-deja/g++.pt/explicit71.C: Adjust expected error.

From-SVN: r75199
This commit is contained in:
Kriang Lerdsuwanakij 2003-12-29 10:16:32 +00:00 committed by Kriang Lerdsuwanakij
parent 24a4a0338a
commit 2f9afd51aa
5 changed files with 32 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2003-12-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/12403
* parser.c (cp_parser_template_declaration_after_export): Set up
template specialization scope in case of explicit specialization.
2003-12-28 Mark Mitchell <mark@codesourcery.com>
PR c++/13081

View File

@ -13961,19 +13961,23 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p)
if (!cp_parser_require (parser, CPP_LESS, "`<'"))
return;
/* Parse the template parameters. */
begin_template_parm_list ();
/* If the next token is `>', then we have an invalid
specialization. Rather than complain about an invalid template
parameter, issue an error message here. */
if (cp_lexer_next_token_is (parser->lexer, CPP_GREATER))
{
cp_parser_error (parser, "invalid explicit specialization");
begin_specialization ();
parameter_list = NULL_TREE;
}
else
parameter_list = cp_parser_template_parameter_list (parser);
parameter_list = end_template_parm_list (parameter_list);
{
/* Parse the template parameters. */
begin_template_parm_list ();
parameter_list = cp_parser_template_parameter_list (parser);
parameter_list = end_template_parm_list (parameter_list);
}
/* Look for the `>'. */
cp_parser_skip_until_found (parser, CPP_GREATER, "`>'");
/* We just processed one more parameter list. */

View File

@ -1,3 +1,9 @@
2003-12-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/12403
* g++.dg/parse/explicit1.C: New test.
* g++.old-deja/g++.pt/explicit71.C: Adjust expected error.
2003-12-28 Mark Mitchell <mark@codesourcery.com>
PR c++/13081

View File

@ -0,0 +1,11 @@
// { dg-do compile }
// Origin: stefaandr@hotmail.com
// PR c++/12403: ICE when explicit specialization is not in
// namespace scope.
struct foo {
template<typename T> void bar (T &t) {}
template<> void bar<double>(double &t) {} // { dg-error "explicit|non-namespace|member" }
};

View File

@ -12,4 +12,4 @@ class bug {
};
template <class X>
template <> // { dg-error "" } invalid specialization
class bug<X>::a<char> {};
class bug<X>::a<char> {}; // { dg-error "" }