Implement -Wswitch-fallthrough

Bernd Schmidt bschmidt@redhat.com
Tue Jul 12 14:22:00 GMT 2016



On 07/12/2016 04:14 PM, Jakub Jelinek wrote:
> On Tue, Jul 12, 2016 at 04:08:02PM +0200, Marek Polacek wrote:
>> On Tue, Jul 12, 2016 at 09:57:01AM -0400, NightStrike wrote:
>>> From http://security.coverity.com/blog/2013/Sep/gimme-a-break.html:
>>
>> Thanks, this is useful.
>>
>>> We also suppress a case label if there is a comment that matches
>>> [^#]fall.?thro?u, even if it's not on the last line.
>>
>> Our current plan is to handle sth like
>> [ \t]*FALL(S | |-)?THR(OUGH|U)\.?[ \t]*
>> [ \t]*Fall(s | |-)?[Tt]hr(ough|u)\.?[ \t]*
>> [ \t]*fall(s | |-)?thr(ough|u)\.?[ \t]*
>
> And
> /*-fallthrough*/
> /*@fallthrough@*/
> //-fallthrough
> //@fallthrough@
> (those 4 as standardized lint comments only in lowercase, the
> above regexps are meant to match the whole comment content, i.e.
> everything between /* and */ or // and \n.

I think this approach is doomed to fail, because it takes only one 
language into account, and fails with preprocessed sources.


Bernd



More information about the Gcc-patches mailing list