public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Joseph S. Myers" <joseph@codesourcery.com>
To: gcc-patches@gcc.gnu.org
Subject: Fix PR c/40033 (ICE-on-invalid)
Date: Sat, 24 Oct 2009 03:59:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.0910240044210.9784@digraph.polyomino.org.uk> (raw)

This patch fixes PR 40033, an ICE-on-invalid regression where
error_mark_node wrongly got wrapped in a C_MAYBE_CONST_EXPR.

Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Applied
to mainline.

2009-10-23  Joseph Myers  <joseph@codesourcery.com>

	PR c/40033
	* c-typeck.c (c_finish_stmt_expr): Do not wrap error_mark_node in
	a C_MAYBE_CONST_EXPR.

testsuite:
2009-10-23  Joseph Myers  <joseph@codesourcery.com>

	PR c/40033
	* gcc.dg/noncompile/pr40033-1.c: New test.

Index: testsuite/gcc.dg/noncompile/pr40033-1.c
===================================================================
--- testsuite/gcc.dg/noncompile/pr40033-1.c	(revision 0)
+++ testsuite/gcc.dg/noncompile/pr40033-1.c	(revision 0)
@@ -0,0 +1,7 @@
+/* ICE from error_mark_node being wrapped in a C_MAYBE_CONST_EXPR.  PR
+   40033.  */
+
+void foo()
+{
+  ({ 0,; }); /* { dg-error "expected" } */
+}
Index: c-typeck.c
===================================================================
--- c-typeck.c	(revision 153496)
+++ c-typeck.c	(working copy)
@@ -8653,11 +8653,13 @@ c_finish_stmt_expr (location_t loc, tree
       goto continue_searching;
     }
 
+  if (last == error_mark_node)
+    return last;
+
   /* In the case that the BIND_EXPR is not necessary, return the
      expression out from inside it.  */
-  if (last == error_mark_node
-      || (last == BIND_EXPR_BODY (body)
-	  && BIND_EXPR_VARS (body) == NULL))
+  if (last == BIND_EXPR_BODY (body)
+      && BIND_EXPR_VARS (body) == NULL)
     {
       /* Even if this looks constant, do not allow it in a constant
 	 expression.  */

-- 
Joseph S. Myers
joseph@codesourcery.com

                 reply	other threads:[~2009-10-24  0:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0910240044210.9784@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).