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]

Patch for bug 20245


This patch fixes bug 20245, an ICE on parse error in the new C parser.  
Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Applied to 
mainline.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2005-02-28  Joseph S. Myers  <joseph@codesourcery.com>

	PR c/20245
	* c-parser.c (c_parser_compound_statement): Return error_mark_node
	instead of NULL_TREE on error.

testsuite:
2005-02-28  Joseph S. Myers  <joseph@codesourcery.com>

	PR c/20245
	* gcc.dg/pr20245-1.c: New test.

diff -rupN GCC.orig/gcc/c-parser.c GCC/gcc/c-parser.c
--- GCC.orig/gcc/c-parser.c	2005-02-25 23:15:44.000000000 +0000
+++ GCC/gcc/c-parser.c	2005-02-28 18:08:20.000000000 +0000
@@ -3170,7 +3170,7 @@ c_parser_compound_statement (c_parser *p
 {
   tree stmt;
   if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
-    return NULL_TREE;
+    return error_mark_node;
   stmt = c_begin_compound_stmt (true);
   c_parser_compound_statement_nostart (parser);
   return c_end_compound_stmt (stmt, true);
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/pr20245-1.c GCC/gcc/testsuite/gcc.dg/pr20245-1.c
--- GCC.orig/gcc/testsuite/gcc.dg/pr20245-1.c	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/pr20245-1.c	2005-02-28 18:09:13.000000000 +0000
@@ -0,0 +1,5 @@
+/* Bug 20245: the parse error should not result in an ICE.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void foo() x; /* { dg-error "expected" } */


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