On Mon, 2016-07-11 at 22:34 +0200, Jakub Jelinek 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
Presumably you mean "case" here? A "break" token is surely the thing we're *not* expecting, right? > (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 > ) > into: > #pragma GCC fallthrough > break > and make sure that if the pragma appears outside of switch or say in > if (...) > #pragma GCC fallthrough > break > and similar spots, then it is actually ignored, rather than affecting > the > parsed code. > Supporting also __builtin_fallthrough (); and [[fallthrough]] is > desirable, > the transformation of the above comments into the pragma should be > controllable by some separate switch? ...or maybe we could detect such comments and store, say, a bitmap of all source_location/location_t values at which we've seen a "fallthrough" style comment, and then have the warning code query this bitmap for a comment in the pertinent range.