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]

Patch for PR c/3259


This patch fixes PR c/3259, a regression in 3.0 relative to 2.95.

Bootstrapped with no regressions on i686-pc-linux-gnu.  Applied to
mainline and branch.

2001-06-22  Joseph S. Myers  <jsm28@cam.ac.uk>

	* c-common.c (verify_tree): Check for x being NULL.
	* doc/c-tree.texi: Document COMPOUND_BODY of an empty
	COMPOUND_STMT.
	Fixes PR c/3259.

testsuite:
2001-06-22  Joseph S. Myers  <jsm28@cam.ac.uk>

	* gcc.dg/20010622-1.c: New test.

--- c-common.c.orig	Tue Jun  5 09:55:05 2001
+++ c-common.c	Fri Jun 22 18:03:16 2001
@@ -1443,6 +1443,11 @@ verify_tree (x, pbefore_sp, pno_sp, writ
   enum tree_code code;
   char class;
 
+  /* X may be NULL if it is the operand of an empty statement expression
+     ({ }).  */
+  if (x == NULL)
+    return;
+
  restart:
   code = TREE_CODE (x);
   class = TREE_CODE_CLASS (code);
--- doc/c-tree.texi.orig	Thu Jun 14 22:40:37 2001
+++ doc/c-tree.texi	Fri Jun 22 18:04:40 2001
@@ -1475,6 +1475,8 @@ should be run in the reverse order of th
 Used to represent a brace-enclosed block.  The first substatement is
 given by @code{COMPOUND_BODY}.  Subsequent substatements are found by
 following the @code{TREE_CHAIN} link from one substatement to the next.
+The @code{COMPOUND_BODY} will be @code{NULL_TREE} if there are no
+substatements.
 
 @item CONTINUE_STMT
 
--- testsuite/gcc.dg/20010622-1.c.orig	Mon Mar 26 23:57:02 2001
+++ testsuite/gcc.dg/20010622-1.c	Fri Jun 22 18:00:19 2001
@@ -0,0 +1,11 @@
+/* Test for segfault doing -Wsequence-point processing on an empty
+   statement expression.  */
+/* Origin: PR c/3259 from <David.Decotigny@irisa.fr>.  */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+void
+f (void)
+{
+  ({ });
+}

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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