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] Fix ICE on invalid computed goto (PR c/37529)


Hi!

gimple_build_goto asserts the argument is a valid gimple operand, but if
gimplification of GOTO_DESTINATION failed, that's not necessarily the case.

Will commit after bootstrap/regtest to trunk.

2008-09-16  Jakub Jelinek  <jakub@redhat.com>

	PR c/37529
	* gimplify.c (gimplify_expr) <case GOTO_EXPR>: If gimplification of
	GOTO_DESTINATION failed, don't create GIMPLE_GOTO.

	* gcc.dg/pr37529.c: New test.

--- gcc/gimplify.c.jj	2008-09-16 13:13:23.000000000 +0200
+++ gcc/gimplify.c	2008-09-16 13:34:32.000000000 +0200
@@ -6483,8 +6483,12 @@ gimplify_expr (tree *expr_p, gimple_seq 
 	  /* If the target is not LABEL, then it is a computed jump
 	     and the target needs to be gimplified.  */
 	  if (TREE_CODE (GOTO_DESTINATION (*expr_p)) != LABEL_DECL)
-	    ret = gimplify_expr (&GOTO_DESTINATION (*expr_p), pre_p,
-				 NULL, is_gimple_val, fb_rvalue);
+	    {
+	      ret = gimplify_expr (&GOTO_DESTINATION (*expr_p), pre_p,
+				   NULL, is_gimple_val, fb_rvalue);
+	      if (ret == GS_ERROR)
+		break;
+	    }
 	  gimplify_seq_add_stmt (pre_p,
 			  gimple_build_goto (GOTO_DESTINATION (*expr_p)));
 	  break;
--- gcc/testsuite/gcc.dg/pr37529.c.jj	2008-09-16 13:36:45.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr37529.c	2008-09-16 13:37:26.000000000 +0200
@@ -0,0 +1,9 @@
+/* PR c/37529 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu89" } */
+
+void
+foo ()
+{
+  goto *;	/* { dg-error "expected expression before" } */
+}

	Jakub


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