This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix cp_parser_enum_specifier (PR c++/38021)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>, Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 5 Nov 2008 15:38:43 +0100
- Subject: [C++ PATCH] Fix cp_parser_enum_specifier (PR c++/38021)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
If type_specifiers.type == error_mark_node, G++ hangs. The problem
is returning from cp_parser_enum_specifier without undoing
cp_parser_parse_tentatively this function has done earlier.
So, either we abort the tentative parse (or commit to it) in this case
and replace the following
if (type_specifiers.type != error_mark_node)
{
some code
}
else
cp_parser_error (parser, "expected underlying type of enumeration");
with just some code, or we leave out the early exit and let the following
code handle it. The following patch does the latter.
Ok for trunk?
2008-11-05 Jakub Jelinek <jakub@redhat.com>
PR c++/38021
* parser.c (cp_parser_enum_specifier): Don't return if
type specifier is errorneous.
* g++.dg/cpp0x/enum1.C: New test.
--- gcc/cp/parser.c.jj 2008-10-29 18:49:05.000000000 +0100
+++ gcc/cp/parser.c 2008-11-05 15:26:34.000000000 +0100
@@ -11827,9 +11827,7 @@ cp_parser_enum_specifier (cp_parser* par
/* Parse the type-specifier-seq. */
cp_parser_type_specifier_seq (parser, /*is_condition=*/false,
&type_specifiers);
- if (type_specifiers.type == error_mark_node)
- return error_mark_node;
-
+
/* If that didn't work, stop. */
if (type_specifiers.type != error_mark_node)
{
--- gcc/testsuite/g++.dg/cpp0x/enum1.C.jj 2008-11-05 15:30:23.000000000 +0100
+++ gcc/testsuite/g++.dg/cpp0x/enum1.C 2008-11-05 15:29:48.000000000 +0100
@@ -0,0 +1,5 @@
+// PR c++/38021
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+auto enum : { do // { dg-error "expected" }
Jakub