On Mon, Jun 17, 2019 at 01:26:37PM -0400, Matthew Beliveau wrote:
> 2019-06-14  Matthew Beliveau  <mbeli...@redhat.com>
>       
>       PR c++/90875 - added -Wswitch-outside-range option
>       * doc/invoke.texi (Wswitch-outside-range): Document.
> 
>       * c-warn.c (c_do_switch_warnings): Implemented new Wswitch-outside-range
>       warning option.
>       
>       * c.opt (Wswitch-outside-range): Added new option.
> 
>       * g++.dg/warn/Wswitch-outside-range-1.C: New test.
>       * g++.dg/warn/Wswitch-outside-range-2.C: New test.
>       * g++.dg/warn/Wswitch-outside-range-3.C: New test.
>       * g++.dg/warn/Wswitch-outside-range-4.C: New test.
> 
> diff --git gcc/c-family/c-warn.c gcc/c-family/c-warn.c
> index 5941c10cddb..b61694af638 100644
> --- gcc/c-family/c-warn.c
> +++ gcc/c-family/c-warn.c
> @@ -1460,8 +1460,9 @@ c_do_switch_warnings (splay_tree cases, location_t 
> switch_location,
>                                      min_value) >= 0)
>           {
>             location_t loc = EXPR_LOCATION ((tree) node->value);
> -           warning_at (loc, 0, "lower value in case label range"
> -                               " less than minimum value for type");
> +           warning_at (loc, OPT_Wswitch_outside_range, "lower value in case"
> +                               " label range less than minimum value"
> +                               " for type");

Just a formatting nit, not a review.  Previously the indentation of the
second part of the string literal made sense, now it doesn't, it shouldn't
start at a location that is not related in any way to the previous line.
Best move the whole string literal to the second line, like:
              warning_at (loc, OPT_Wswitch_outside_range,
                          "lower value in case label range less than minimum"
                          " value for type");
Happens multiple times in the patch.

        Jakub

Reply via email to