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 ) 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? Jakub