This is the mail archive of the 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]

Re: [c++ PATCH] PR 29087 (ice on valid code)

Steven Bosscher wrote:

	* parser.c (cp_parser_labeled_statement): Return nothing.
	Rename to cp_parser_label_for_labeled_statement.  Parse only
	the label, not the statement.
	(cp_parser_statement): Parse the statement of a labeled-statement
	from here, using tail recursion.


Minor change:

-/* Parse a labeled-statement.
+   This function is only called by cp_parser_statement.  We can use
+   this to avoid extremely deep recursion (e.g. PR29087): In this
+   function we only parse up to `statement', and then we return to
+   cp_parser_statement to parse `statement' there.  So the bits we
+   parse here are:

Please adjust this comment to retain the description of IN_COMPOUND, which it looks like you removed. Also, please remove the PR number, as the comments in the code ought to stand on their own.

Just say something like:

/* Parse the label for a labeled-statement, i.e.:

+   identifier :
+   case constant-expression :
+   case constant-expression ... constant-expression :
+   default :
+   When a label is parsed without errors, the label is added to the
+   parse tree by the finish_* functions, so this function doesn't
+   have to return the label.  */

The rationale is evident from the manual "restart" in the caller.


Mark Mitchell
(650) 331-3385 x713

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