This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Implement -Wimplicit-fallthrough (version 9)
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Marek Polacek <polacek at redhat dot com>, Markus Trippelsdorf <markus at trippelsdorf dot de>, Eric Botcazou <ebotcazou at adacore dot com>, gcc-patches at gcc dot gnu dot org, Jason Merrill <jason at redhat dot com>, Rainer Orth <ro at cebitec dot uni-bielefeld dot de>, Joseph Myers <joseph at codesourcery dot com>, Arnaud Charlet <charlet at adacore dot com>
- Date: Tue, 27 Sep 2016 06:51:31 -0500
- Subject: Re: Implement -Wimplicit-fallthrough (version 9)
- Authentication-results: sourceware.org; auth=none
- References: <20160920153343.GF19950@redhat.com> <3916173.q8VWCuMk9Z@polaris> <20160927081744.GL7282@tucnak.redhat.com> <1630018.CAxBrgp0y6@polaris> <20160927103941.GC307@x4> <20160927104750.GP7282@tucnak.redhat.com> <20160927105628.GT3223@redhat.com> <20160927113115.GR7282@tucnak.redhat.com>
On Tue, Sep 27, 2016 at 01:31:15PM +0200, Jakub Jelinek wrote:
> I think it is important to think in terms of what regexps we still want to
> match, even when the matching is actually implemented in C, not using
> regexps. And yes, you list one reason why arbitrary text with fall and
> through somewhere in it is not a good idea. Another:
> /* XXX Really fallthru? */
> (what we have in pch.c).
> So, if you want to allow ... fall through ... and else fall through, and
> perhaps // fall through - some explanation
> then it might be e.g.
> //-fallthrough$
> //@fallthrough@$
> /\*-fallthrough\*/
> /\*@fallthrough@\*/
> //[ \t.]*(ELSE )?FALL(S | |-)?THR(OUGH|U)[ \t.]*(-.*)?$
> //[ \t.]*(Else )?Fall(s | |-)?[Tt]hr(ough|u)[ \t.]*(-.*)?$
> //[ \t.]*(else )?fall(s | |-)?thr(ough|u)[ \t.]*(-.*)?$
> /\*[ \t.]*(ELSE )?FALL(S | |-)?THR(OUGH|U)[ \t.]*(-.*)?\*/
> /\*[ \t.]*(Else )?Fall(s | |-)?[Tt]hr(ough|u)[ \t.]*(-.*)?\*/
> /\*[ \t.]*(else )?fall(s | |-)?thr(ough|u)[ \t.]*(-.*)?\*/
> where . would match even newlines in the last 3,
> but $ would always match just end of line?
Any comment with text
^[^_[:alnum:]]*(else )?fall(s | |-)?thr(ough|u)[^_[:alnum:]]*$
perhaps? Case-insensitive. Or allow any amount of space, or even any
interpunction. Just don't allow any alphanumerics except for those
exact words, and there won't be many false hits at all.
Segher