Re: [RFC PATCH] compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use

From: Linus Torvalds
Date: Sun Aug 04 2019 - 14:09:46 EST


On Sun, Aug 4, 2019 at 11:01 AM Joe Perches <joe@xxxxxxxxxxx> wrote:
>
> Linus? Do you have an opinion about this RFC/patch?

So my only real concern is that the comment approach has always been
the really traditional one, going back all the way to 'lint' days.

And you obviously cannot use a #define to create a comment, so this
whole keyword model will never be able to do that.

At the same time, all the modern tools we care about do seem to be
happy with it, either through the gcc attribute, the clang
[[clang:fallthrough]] or the (eventual) standard C [[fallthrough]]
model.

So I'm ok with just saying "the comment model may be traditional, but
it's not very good".

I didn't look at all the patches, but the one I *did* see had a few issues:

- it didn't seem to handle clang

- we'd need to make -Wimplicit-fallthrough be dependent on the
compiler actually supporting the attribute, not just on supporting the
flag.

without those changes, nobody can actually start doing any
conversions. But I assume such patches exist somewhere, and I've just
missed them.

Linus