This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] Fix cp_parser_enum_specifier (PR c++/38021)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]