On Tue, Jul 12, 2016 at 04:22:30PM +0200, Bernd Schmidt wrote: > 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.
It takes C/C++/ObjC/ObjC++ into account (I believe Go has fallthrough keyword in the language, but perhaps it handles everything in the FE). For C++11, people can use [[gnu::fallthrough]], for C++17 [[fallthrough]] (standardized), and we are going to offer some other way in all cases (__builtin_fallthrough () and/or #pragma GCC fallthrough). The parsing of comments is just an attempt to handle the most common case in user-friendly way. For non-integrated preprocessing, the options are either let people use some other way than comment, recommend them to use -C or -CC, add some new option like -C/-CC that emits during preprocessing standardized /*FALLTHROUGH*/ comments only when before case/default keywords or identifier followed by semicolon into the -E output, or emitting #pragma GCC fallthrough in that case instead. As usual for warnings, changes are contentious, on the other side as could be seen in the patchset Marek posted it discovered multiple real bugs in GCC already. Jakub