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]

New C parser, version 8

Here is a new parser patch fixing an infinite loop in error recovery noted 
on IRC.  Incremental patch, and testcase for the bug (which has been added 
to mainline), below; full patch attached.  Bootstrapped with no 
regressions on x86_64-unknown-linux-gnu.  I had previously audited for 
infinite loops in error recovery but then I was looking specifically for 
such loops at EOF and not the sort of case found here.

2005-02-09  Joseph S. Myers  <>

	* c-parser.c: New file.
	* Remove.
	* (c-parse.o-warn, c-parse.o, c-parse.c, c-parse.y):
	(c-parser.o): Add dependencies.
	(C_AND_OBJC_OBJC, C_OBJS, gcc.srcextra, GTFILES, distclean,
	maintainer-clean, TAGS): Update.
	* (gtfiles): Update.
	* gengtype-lex.l: Don't handle "@@".
	* stub-objc.c (objc_get_class_ivars, objc_build_throw_stmt,
	objc_build_synchronized, objc_begin_try_stmt,
	objc_begin_catch_clause, objc_finish_catch_clause,
	objc_build_finally_clause, objc_finish_try_stmt): New.
	* c-tree.h (struct c_declspecs): Add declspecs_seen_p and
	(c_parse_init): Update comment.
	* c-decl.c (c_init_decl_processing): Update comment.
	(build_null_declspecs, declspecs_add_qual, declspecs_add_type,
	declspecs_add_scspec, declspecs_add_attrs): Initialize and update
	new c_declspecs members.

2005-02-09  Joseph S. Myers  <>

	* (objc/objc-parse.o-warn, objc/objc-parse.o,
	objc/objc-parse.c, objc/objc-parse.y): Remove
	(OBJC_OBJS, objc.srcextra, objc.tags, objc.mostlyclean,
	objc.distclean, objc.maintainer-clean): Update for new parser.
	* (gtfiles): Update for new parser.

2005-02-09  Joseph S. Myers  <>

	* gcc.dg/cpp/separate-1.c, gcc.dg/noncompile/971104-1.c,
	gcc.dg/noncompile/990416-1.c: Adjust expected messages for new

--- c-parser.c-v7	2005-02-02 12:18:19.000000000 +0000
+++ c-parser.c-v8	2005-02-09 00:47:14.000000000 +0000
@@ -3536,6 +3536,15 @@ c_parser_statement_after_labels (c_parse
     case CPP_SEMICOLON:
       c_parser_consume_token (parser);
+    case CPP_CLOSE_PAREN:
+      /* Avoid infinite loop in error recovery:
+	 c_parser_skip_until_found stops at a closing nesting
+	 delimiter without consuming it, but here we need to consume
+	 it to proceed further.  */
+      c_parser_error (parser, "expected statement");
+      c_parser_consume_token (parser);
+      break;
       stmt = c_finish_expr_stmt (c_parser_expression (parser).value);

/* Test for infinite loop in parser error recovery.  From Serge
   Belyshev <ssb> on IRC.  */
/* { dg-do compile } */
/* { dg-options "" } */
int f() { return 1); } /* { dg-error "parse|syntax|expected" } */

Joseph S. Myers      (personal mail) (CodeSourcery mail) (Bugzilla assignments and CCs)

Attachment: c-parser-patch-version-8.gz
Description: Binary data

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