[C PATCH] Better location for switch warnings (PR c/30020)
Jeff Law
law@redhat.com
Wed Jun 4 07:08:00 GMT 2014
On 06/04/14 00:46, Marek Polacek wrote:
> It is trivial to pass the location from c_add_case_label down to
> check_case_bounds, so do that. With it, we instead of
>
> i.c:4:3: warning: case label value is less than minimum value for type
> switch (c) { case 42: case -1: return -1; };
> ^
> output
> i.c:4:25: warning: case label value is less than minimum value for type
> switch (c) { case 42: case -1: return -1; };
> ^
> which is better.
>
> Tested x86_64, ok for trunk?
>
> 2014-06-04 Marek Polacek <polacek@redhat.com>
>
> PR c/30020
> * c-common.c (check_case_bounds): Add location parameter.
> Use it.
> (c_add_case_label): Pass loc to check_case_bounds.
>
> * c-c++-common/pr30020.c: New test.
OK.
ISTM that additional patches of this nature (add location parameter to
get better diagnostics) ought to be considered pre-approved.
jeff
More information about the Gcc-patches
mailing list