On Tue, Apr 9, 2019 at 2:39 PM Jakub Jelinek <ja...@redhat.com> wrote:
> On Tue, Apr 09, 2019 at 09:06:33AM +0200, Jakub Jelinek wrote:
> > Alternatively, I believe we could remove from the patch the in-place
> > replacement of CASE_LABEL_EXPRs with LABEL_EXPRs if we want to remove,
> > just splay_tree_remove those, because by my reading of
> > preprocess_case_label_vec_for_gimple we also ignore the fully out of range
> > CASE_LABEL_EXPRs there, shall I tweak the patch and rebootstrap?
>
> Here is a version of the patch that doesn't overwrite those CASE_LABEL_EXPRs
> as gimplifier handles those, just removes them from the splay tree.
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2019-04-09  Jakub Jelinek  <ja...@redhat.com>
>
>         PR c/89888
>         * c-common.h (c_add_case_label): Remove orig_type and outside_range_p
>         arguments.
>         (c_do_switch_warnings): Remove outside_range_p argument.
>         * c-common.c (check_case_bounds): Removed.
>         (c_add_case_label): Remove orig_type and outside_range_p arguments.
>         Don't call check_case_bounds.  Fold low_value as well as high_value.
>         * c-warn.c (c_do_switch_warnings): Remove outside_range_p argument.
>         Check for case labels outside of range of original type here and
>         adjust them.
> c/
>         * c-typeck.c (struct c_switch): Remove outside_range_p member.
>         (c_start_case): Don't clear it.
>         (do_case): Adjust c_add_case_label caller.
>         (c_finish_case): Adjust c_do_switch_warnings caller.
> cp/
>         * decl.c (struct cp_switch): Remove outside_range_p member.
>         (push_switch): Don't clear it.
>         (pop_switch): Adjust c_do_switch_warnings caller.
>         (finish_case_label): Adjust c_add_case_label caller.

> +      node = splay_tree_predecessor (cases, (splay_tree_key) min_value);
...
> +         if (CASE_HIGH ((tree) node->value)
> +             && tree_int_cst_compare (CASE_HIGH ((tree) node->value),
> +                                      min_value) >= 0)
...
> +             node = splay_tree_predecessor (cases,
> +                                            (splay_tree_key) min_value);
....
> +      node = splay_tree_lookup (cases, (splay_tree_key) max_value);
> +      if (node == NULL)
> +       node = splay_tree_predecessor (cases, (splay_tree_key) max_value);
> +      /* Handle a single node that might partially overlap the range.  */
> +      if (node
> +         && node->key
> +         && CASE_HIGH ((tree) node->value)
> +         && tree_int_cst_compare (CASE_HIGH ((tree) node->value),
> +                                  max_value) > 0)
...
> +      while ((node = splay_tree_successor (cases,
> +                                          (splay_tree_key) max_value))

Hmm, why are the code sections for dealing with the lower bound and
upper bound asymmetrical?  That is, why not start the upper bound
consideration with splay_tree_successor?

Jason

Reply via email to