Closed akopytov closed 6 years ago
Thanks a lot for taking care of this ! This is getting really annoying. But surely adding them at the beginning of switch is useless ?
Clang supports /* All fallthrough */
annotations that can be used before a switch
. Unfortunately that form is not (yet?) supported by GCC. I checked with gcc (Ubuntu 7.2.0-8ubuntu3) 7.2.0
from Ubuntu Artful.
I understand, but there :
 switch(len & 3)  {  + / fall through / I certainly hope this is not needed there, before any "case" :)
Hm, not sure I understand that comment. I'm quoting the GCC manual:
The comment needs to be followed after optional whitespace and other comments by case or default keywords or by a user label that precedes some case or default label.
Unless I'm missing something, that's what the patch does, i.e. each annotation being added is followed by a case
statement with an implicit fallthrough? For example, the first comment right after the switch
statement is meant to quiet the warning generated by the first case
statement,
Do you get a warning if you don't have it ? In my understanding, you're only falling through one case statement to another, so that should not happen for the first one ? Of course, it wouldn't be the first time I'm wrong :)
You were right, it was me who misunderstood the manual :) The comment right after the switch
is indeed redundant, as seen from examples in the manual. Resubmitted the patch.
Merged, thanks a lot !
Annotate fall through cases in switch statements where that behavior is desirable to quiet compiler warnings with the -Wimplicit-fallthrough flag. The annotation format used is supported by both GCC and Clang.
Fixes #108.