This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/7652] -Wswitch-break : Warn if a switch case falls through
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 30 Apr 2014 16:40:42 +0000
- Subject: [Bug c/7652] -Wswitch-break : Warn if a switch case falls through
- Auto-submitted: auto-generated
- References: <bug-7652-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
--- Comment #29 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #26)
> (In reply to Florian Weimer from comment #25)
> > Do we have such attributes in the C compiler?
>
> No, AFAICS. Perhaps we could invent __builtin_fallthrough or some such.
I like the previous suggestion of using "goto LABEL;". In fact, the warning
message could explicitly say "use %<goto %D;%> to silence this warning".
(In reply to Florian Weimer from comment #25)
>
> In the end, need general (syntax-based) unreachable-code detection, so that
> return statements and no-return functions suppress the warning as well, and
> so on. At least if this will be part of -Wall.
For trivial cases, it should be just a matter of checking the type of the
previous statement in c_stmt_ends_with_goto.