On Wed, Sep 28, 2016 at 09:29:01AM -0600, Tom Tromey wrote: > >>>>> "Michael" == Michael Matz <m...@suse.de> writes: > > Michael> Not accepting > Michael> /* And here we intentionally fall through because ... */ > Michael> and forcing users to replace this by: > Michael> /* fallthrough */ > Michael> is not robust either. It's actually actively lowering robustness of > code, > Michael> it creates work for programmers that will be regarded as pointless > (and > Michael> rightly so) and will merely lead to everybody disabling the warning > (see > Michael> our generated files) > > We can't control what programmers might do. My point is that accepting > too much is actively bad -- it hides errors. If this somehow makes some > programmer fall down a slippery slope, well, that's their error, not > gcc's. > > TBH I think it would be better not to parse comments at all. Heuristics > are generally bad and this case and ensuing discussion is a great > demonstration of that. > > The other day I built gdb with -Wimplicit-fallthrough. I was surprised > to find that gcc rejected this: > > default: > { > complaint (&symfile_complaints, > _("Storage class %d not recognized during scan"), > sclass); > } > /* FALLTHROUGH */ > > /* C_FCN is .bf and .ef symbols. I think it is sufficient > to handle only the C_FUN and C_EXT. */ > case C_FCN: > > Presumably without the comment heuristic, this would be accepted.
Is complaint a noreturn call? If not, then it would certainly warn, unless there is [[fallthrough]]; or __attribute__((fallthrough)); etc. (or the comment). For the comment, /* FALLTHROUGH */ is the recognized spelling of the comment, but right now we only look for such comments immediately before a case/default keyword or user label; if there is another comment in between, it is ignored. This is something we are considering to change, exactly because often the /* FALLTHRU */ comment appears after some case and then there is unrelated comment before the next case about what that case handles. Jakub