This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Implement -Wswitch-fallthrough


On Mon, Jul 11, 2016 at 4:34 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Mon, Jul 11, 2016 at 10:23:30PM +0200, Marek Polacek wrote:
>> On Mon, Jul 11, 2016 at 01:18:02PM -0700, Andi Kleen wrote:
>> > > I explained why supporting the classic lint style comment wouldn't fly.
>> >
>> > Not convincing, it worked fine for 30+ years of lints.
>>
>> So how can the compiler handle
>> /* Never ever fall through here */
>> ?
>
> It can't.  But it perhaps could handle a couple of documented most common
> comment styles, perhaps only if followed by break token, and turn say
> /* FALLTHROUGH */
> break
> (and say:
> /* FALL THROUGH */
> /* FALLTHRU */
> /* FALL THRU */
> /*-fallthrough*/
> /* Fallthrough */
> /* Fall through */
> /* Fallthru */
> /* Fall thru */
> /* fallthrough */
> /* fall through */
> /* fallthru */
> /* fall thru */
> // FALLTHROUGH
> // FALL THROUGH
> // FALLTHRU
> // FALL THRU
> //-fallthrough
> // Fallthrough
> // Fall through
> // Fallthru
> // Fall thru
> // fallthrough
> // fall through
> // fallthru
> // fall thru

>From http://security.coverity.com/blog/2013/Sep/gimme-a-break.html:

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.

Maybe that's enough?

The page has other exclusions that might be desirable.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]