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

From: hpa
Date: Thu Aug 01 2019 - 16:12:49 EST


On August 1, 2019 5:24:29 AM PDT, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>On Wed, Jul 31, 2019 at 11:10:36PM -0700, hpa@xxxxxxxxx wrote:
>> On July 31, 2019 4:55:47 PM PDT, Miguel Ojeda
><miguel.ojeda.sandonis@xxxxxxxxx> wrote:
>> >On Wed, Jul 31, 2019 at 11:01 PM <hpa@xxxxxxxxx> wrote:
>> >>
>> >> The standard is moving toward adding this as an attribute with the
>> >[[fallthrough]] syntax; it is in C++17, not sure when it will be in
>C
>> >be if it isn't already.
>> >
>> >Not yet, but it seems to be coming:
>> >
>> > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2268.pdf
>> >
>> >However, even if C2x gets it, it will be quite a while until the GCC
>> >minimum version gets bumped up to that, so...
>> >
>> >Cheers,
>> >Miguel
>>
>> The point was that we should plan ahead in whatever we end up doing.
>
>By reserving 'fallthrough' as a keyword we do exactly that. We can then
>define it to whatever the compiler/tool at hand requires.
>
>Once GCC gains support for that [[attribute]] nonsense, we can detector
>that and use that over the __attribute__(())
>
>[ Also the Cxx attribute syntax is an abomination -- just a lesser one
>than reading actual comments :-) ]

I'm not disagreeing... I think using a macro makes sense.

Not sure if I agree about the syntax... I think it's rather friendly compared to gcc's ;)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.