re PR c++/18123 (ICE on templated enum)

PR c++/18123
	* parser.c (cp_parser_type_specifier): Catch template declaration
	of enum.

	* g++.dg/parse/enum2.C: New test.
	* g++.old-deja/g++.pt/enum5.C: Adjust error location.

From-SVN: r91630
This commit is contained in:
Kriang Lerdsuwanakij 2004-12-02 11:34:56 +00:00 committed by Kriang Lerdsuwanakij
parent 1a06672a3b
commit a5e515185a
5 changed files with 30 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2004-12-02 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/18123
* parser.c (cp_parser_type_specifier): Catch template declaration
of enum.
2004-12-01 Matt Austern <austern@apple.com>
* name-lookup.c (namespace_binding): Omit alias check for global namespace.

View File

@ -9130,7 +9130,15 @@ cp_parser_type_specifier (cp_parser* parser,
&& cp_lexer_peek_nth_token (parser->lexer, 3)->type
== CPP_OPEN_BRACE))
{
type_spec = cp_parser_enum_specifier (parser);
if (parser->num_template_parameter_lists)
{
error ("template declaration of %qs", "enum");
cp_parser_skip_to_end_of_block_or_statement (parser);
type_spec = error_mark_node;
}
else
type_spec = cp_parser_enum_specifier (parser);
if (declares_class_or_enum)
*declares_class_or_enum = 2;
if (decl_specs)

View File

@ -1,3 +1,9 @@
2004-12-02 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/18123
* g++.dg/parse/enum2.C: New test.
* g++.old-deja/g++.pt/enum5.C: Adjust error location.
2004-12-02 Nick Clifton <nickc@redhat.com>
* gcc.target/xstormy16: New test directory.

View File

@ -0,0 +1,7 @@
// { dg-do compile }
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
// PR c++/18123: ICE pushing tag from invalid template.
template<int> enum E { e }; // { dg-error "template declaration" }

View File

@ -1,4 +1,4 @@
// { dg-do assemble }
template <>
enum E {e}; // { dg-error "" } template declaration of enum
template <> // { dg-error "" } template declaration of enum
enum E {e};