* [tuples] Don't ICE if a switch() only has the default label
@ 2007-08-01 17:09 Diego Novillo
0 siblings, 0 replies; only message in thread
From: Diego Novillo @ 2007-08-01 17:09 UTC (permalink / raw)
To: gcc-patches
[-- 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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-08-01 17:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-01 17:09 [tuples] Don't ICE if a switch() only has the default label Diego Novillo
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).