This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING] Re: [PATCH] Fix-it hints for -Wimplicit-fallthrough
- From: Marek Polacek <polacek at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: David Malcolm <dmalcolm at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 6 Jun 2017 15:12:42 +0200
- Subject: Re: [PING] Re: [PATCH] Fix-it hints for -Wimplicit-fallthrough
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=polacek at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2F9B24DD62
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2F9B24DD62
- References: <1493921803-37798-1-git-send-email-dmalcolm@redhat.com> <1495828794.9289.82.camel@redhat.com> <9aa52616-0cbf-31df-a18e-0ea9fbaf8db3@gmail.com>
On Fri, May 26, 2017 at 02:13:56PM -0600, Martin Sebor wrote:
> On 05/26/2017 01:59 PM, David Malcolm wrote:
> > Ping:
> > https://gcc.gnu.org/ml/gcc-patches/2017-05/msg00334.html
> >
> > On Thu, 2017-05-04 at 14:16 -0400, David Malcolm wrote:
> > > As of r247522, fix-it-hints can suggest the insertion of new lines.
> > >
> > > This patch updates -Wimplicit-fallthrough to provide suggestions
> > > with fix-it hints, showing the user where to insert "break;" or
> > > fallthrough attributes.
> > >
> > > For example:
> > >
> > > test.c: In function 'set_x':
> > > test.c:15:9: warning: this statement may fall through [-Wimplicit
> > > -fallthrough=]
> > > x = a;
> > > ~~^~~
> > > test.c:22:5: note: here
> > > case 'b':
> > > ^~~~
> > > test.c:22:5: note: insert '__attribute__ ((fallthrough));' to
> > > silence this warning
> > > + __attribute__ ((fallthrough));
> > > case 'b':
> > > ^~~~
> > > test.c:22:5: note: insert 'break;' to avoid fall-through
> > > + break;
> > > case 'b':
> > > ^~~~
>
> I haven't read the patch but the notes above make me wonder:
>
> If the location of at least one of t hints is always the same
> as that of the first "note: here" would it make sense to lose
> the latter and reduce the size of the output? (Or lose it in
> the cases where one of the fix-it hints does share a location
> with it).
I agree that it's a tad verbose but I'm not sure if it'd be easy
to suppress printing
case 2:
^~~~
more times simple enough. So I'd be fine with the current state.
I'd also be happy with e.g.
a.c: In function ‘foo’:
a.c:7:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
x = 1;
~~^~~
a.c:8:5: note: here
case 2:
^~~~
a.c:8:5: note: insert ‘__attribute__ ((fallthrough));’ to silence this warning
+ __attribute__ ((fallthrough));
or insert ‘break;’ to avoid fall-through
+ break;
but I don't think we've got the means to do so.
On the patch, I'd think that add_newline_fixit_with_indentation doesn't
belong to gimplify.c, even though it only has one user. But I won't be
able to approve it in any case.
Marek