This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Implement -Wswitch-fallthrough
- From: Marek Polacek <polacek at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 Jul 2016 22:20:09 +0200
- Subject: Re: Implement -Wswitch-fallthrough
- Authentication-results: sourceware.org; auth=none
- References: <20160711194340.GI13963@redhat.com> <2712180.odMs7cdt2D@polaris> <20160711201152.GS7387@tucnak.redhat.com>
On Mon, Jul 11, 2016 at 10:11:52PM +0200, Jakub Jelinek wrote:
> On Mon, Jul 11, 2016 at 10:08:02PM +0200, Eric Botcazou wrote:
> > > After I'd completed the warning, I kicked off a bootstrap so as to add
> > > various gcc_fallthrough calls. There were a good amount of them, as
> > > expected. I also grepped various FALLTHRU/Falls through/...fall
> > > thru.../... comments in config/ and added gcc_fallthroughs to make it
> > > easier for people. Wherever I wasn't sure that the gcc_fallthrough was
> > > appropriate, I added an 'XXX' comment. This must not be relied upon as I
> > > don't know most of the compiler code. The same goes for relevant libraries
> > > where I introduced various gomp_fallthrough macros conditional on __GNUC__
> > > (I'd tried to use a configure check but then decided I won't put up with
> > > all the vagaries of autoconf).
> >
> > Do we really want to clutter up the entire tree like that? The result is
> > particularly ugly IMO. Just add -Wno-switch-fallthrough somewhere I'd say.
I think that if *we* refuse to use __builtin_fallthrough, then we can't
expect users to use it.
> Well, we already have the /* FALLTHRU */ etc. comments in most of the
> places. Perhaps if we replace those comments just with GCC_FALLTHRU,
> a macro that expands to __builtin_fallthrough (); for GCC >= 7, or
> to [[fallthrough]] for C++17, or nothing?
> IMHO it doesn't make sense to keep both the gomp_fallthrough (); macro and
> /* FALLTHROUGH */ etc. comments in the source.
Yea, that's a possibility, though sometimes the comment explains why the
fall through is desirable.
Marek