+2016-11-10 Martin Liska <mliska@suse.cz>
+
+ PR sanitizer/78270
+ * gimplify.c (gimplify_switch_expr): Create live_switch_vars
+ only when SWITCH_BODY is a BIND_EXPR.
+
2016-11-10 Pierre-Marie de Rodat <derodat@adacore.com>
PR debug/78112
{
vec<tree> labels;
vec<tree> saved_labels;
- hash_set<tree> *saved_live_switch_vars;
+ hash_set<tree> *saved_live_switch_vars = NULL;
tree default_case = NULL_TREE;
gswitch *switch_stmt;
labels. Save all the things from the switch body to append after. */
saved_labels = gimplify_ctxp->case_labels;
gimplify_ctxp->case_labels.create (8);
- saved_live_switch_vars = gimplify_ctxp->live_switch_vars;
- gimplify_ctxp->live_switch_vars = new hash_set<tree> (4);
+
+ /* Do not create live_switch_vars if SWITCH_BODY is not a BIND_EXPR. */
+ if (TREE_CODE (SWITCH_BODY (switch_expr)) == BIND_EXPR)
+ {
+ saved_live_switch_vars = gimplify_ctxp->live_switch_vars;
+ gimplify_ctxp->live_switch_vars = new hash_set<tree> (4);
+ }
+
bool old_in_switch_expr = gimplify_ctxp->in_switch_expr;
gimplify_ctxp->in_switch_expr = true;
labels = gimplify_ctxp->case_labels;
gimplify_ctxp->case_labels = saved_labels;
- gcc_assert (gimplify_ctxp->live_switch_vars->elements () == 0);
- delete gimplify_ctxp->live_switch_vars;
+
+ if (gimplify_ctxp->live_switch_vars)
+ {
+ gcc_assert (gimplify_ctxp->live_switch_vars->elements () == 0);
+ delete gimplify_ctxp->live_switch_vars;
+ }
gimplify_ctxp->live_switch_vars = saved_live_switch_vars;
preprocess_case_label_vec_for_gimple (labels, index_type,