This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/17843] Warning not given for unreachable code in a switch
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Aug 2008 10:49:23 -0000
- Subject: [Bug middle-end/17843] Warning not given for unreachable code in a switch
- References: <bug-17843-9409@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #8 from manu at gcc dot gnu dot org 2008-08-13 10:49 -------
@Bernhard
You need to properly submit the patch to gcc-patches (plus copyright assignment
in place, testcases, changelog)?
See http://gcc.gnu.org/contribute.html
As for the patch itself. Notice that c_do_switch_warnings returns before your
code
if (!warn_switch && !warn_switch_enum && !warn_switch_default)
return;
If you make your warning conditional on Wunreachable-code, you need to add
warn_unreachable_code to that test. Alternatively, make it conditional on
-Wswitch and it will work. Then, you should use warning (OPT_Wswitch, "").
Also, you should pass to warning a explicit location (ideally, the one
corresponding ot the default label or if that is not possible, then the one of
the switch):
warning (OPT_Wswitch, "%Hwarning", &location);
Bonus points if the code for this and enums could be merged somehow!
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17843