From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1627 invoked by alias); 17 Sep 2012 22:02:51 -0000 Received: (qmail 1617 invoked by uid 22791); 17 Sep 2012 22:02:48 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED,TW_XF X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 17 Sep 2012 22:02:35 +0000 From: "alexfh at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/7652] -Wswitch-break : Warn if a switch case falls through Date: Mon, 17 Sep 2012 22:02:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: alexfh at google dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-09/txt/msg01307.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652 Alexander Kornienko changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |alexfh at google dot com --- Comment #13 from Alexander Kornienko 2012-09-17 22:00:49 UTC --- (In reply to comment #12) > However, I think it's important to note that they implement the very noisy > behavior of warning for all implicit fall-through. We could make our warning > much more useful by being silent for empty case statements, FYI, clang's warning does exactly this, i.e. it doesn't (and never did) warn on empty case labels. There's also a way to silence this warning in cases where fallthrough is intended: [[clang::fallthrough]]; construct, which uses custom C++11 statement attribute clang::fallthrough. There's a doc here: http://clang.llvm.org/docs/LanguageExtensions.html#clang__fallthrough In an ideal world, it would be great if GCC had a compatible implementation using C++11 attributes (except for a namespace of the attribute), or for example, using a built-in function. So that it was possible to have the same syntax in source code, at least using a macro. Command-line flags compatibility would also be nice. Or if you have any reasonable suggestions on how this diagnostic can be made better, I'll be glad to discuss this. > and in light of > other warnings starting with -Wswitch, I would recommend we name the warning > -Wswitch-fall-through or something similar. If we want to have an additional > warning that warns for all fall-through, as clang does, we could also add > -Wswitch-empty-fall-through.