[PATCH v2] Add fallthrough attributes

Joshua Watt jpewhacker@gmail.com
Fri Feb 9 14:19:00 GMT 2018

On Fri, 2018-02-09 at 10:26 +0100, Mark Wielaard wrote:
> On Fri, Feb 09, 2018 at 10:08:09AM +0100, Ulf Hermann wrote:
> > > [...]
> > > +#ifdef HAVE_FALLTHROUGH
> > > +      __attribute__ ((fallthrough));
> > > +#endif
> > > [...]
> > 
> > I would like to see this stanza wrapped in a macro, so that we only
> > have one "#ifdef HAVE_FALLTHROUGH" in the code, not another one in
> > every place we want to fall through. See the "internal_function"
> > macro defined in lib/eu-config.h for a similar case.
> Agreed. Having 4 lines for a fallthrough instead of 1 is really too
> much. Also could you explain a bit more why you would like this?
> The advantage of the comments really is that they should work
> everywhere.

I'm attempting to build Yocto using Icecream to do distributed
compiling. Icecream pre-processes the file before sending it to the
remote compiling node, thus removing the comments and triggering the

There is a fix in Icecream to allow it to not remove comments when pre-
processing, but it will be a while before that change (which hasn't
been released yet) trickles down to all the end Icecream users. I
figured making the change here wouldn't hurt in the meantime.

> If the comment really doesn't work in your situation maybe we could
> do
> like gnulib did:
> http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=11fdf80b21f2b4
> 0a10687b9a3d16c852b19d512c
> The idea is that those versions of GCC that support
> -Wimplicit-fallthrough also have support for the __attribute__
> ((fallthrough)) statement. So they can always be used together.

Yes, that is cleaner and makes more sense. I will change my patch to do

Joshua Watt

> Cheers,
> Mark

More information about the Elfutils-devel mailing list