public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Diego Novillo <dnovillo@google.com>
To: gcc-patches@gcc.gnu.org
Subject: [tuples] Don't ICE if a switch() only has the default label
Date: Wed, 01 Aug 2007 17:09:00 -0000	[thread overview]
Message-ID: <46B0BE18.40104@google.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]


This fixes a couple of tests in compile.exp.  If a switch only has the
default label, the call to sort_case_labels in gimplify_switch_expr()
was segfaulting as the vector was empty.



[-- Attachment #2: 20070801-fix-switch-exprs-with-0-labels.diff --]
[-- Type: text/x-patch, Size: 1948 bytes --]

2007-08-01  Diego Novillo  <dnovillo@google.com>

	* gimplify.c (gimplify_switch_expr): Do not call sort_case_labels
	if there are no labels other than 'default'.
	* gimple.h (gimple_num_ops, gimple_op, gimple_set_op): Use
	result of GIMPLE_RANGE_CHECK call.

Index: gimplify.c
===================================================================
--- gimplify.c	(revision 127104)
+++ gimplify.c	(working copy)
@@ -1455,7 +1455,9 @@ gimplify_switch_expr (tree *expr_p, gimp
 	  default_case = gimple_label_label (new_default);
 	}
 
-      sort_case_labels (labels);
+      if (!VEC_empty (tree, labels))
+	sort_case_labels (labels);
+
       gimple_switch = build_gimple_switch_vec (SWITCH_COND (switch_expr), 
                                                default_case, labels);
       gimple_add (pre_p, gimple_switch);
Index: gimple.h
===================================================================
--- gimple.h	(revision 127104)
+++ gimple.h	(working copy)
@@ -472,24 +472,24 @@ extern void gimple_range_check_failed (c
 static inline size_t
 gimple_num_ops (gimple gs)
 {
-  GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
-  return gs->with_ops.num_ops;
+  gimple g = GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
+  return g->with_ops.num_ops;
 }
 
 static inline tree
 gimple_op (gimple gs, size_t i)
 {
-  GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
-  gcc_assert (i < gs->with_ops.num_ops);
-  return gs->with_ops.op[i];
+  gimple g = GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
+  gcc_assert (i < g->with_ops.num_ops);
+  return g->with_ops.op[i];
 }
 
 static inline void
 gimple_set_op (gimple gs, size_t i, tree op)
 {
-  GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
-  gcc_assert (i < gs->with_ops.num_ops);
-  gs->with_ops.op[i] = op;
+  gimple g = GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
+  gcc_assert (i < g->with_ops.num_ops);
+  g->with_ops.op[i] = op;
 }
 
 

                 reply	other threads:[~2007-08-01 17:09 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=46B0BE18.40104@google.com \
    --to=dnovillo@google.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).