From patchwork Thu Nov 3 11:51:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 80642 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp588992qge; Thu, 3 Nov 2016 04:51:48 -0700 (PDT) X-Received: by 10.99.173.3 with SMTP id g3mr13414743pgf.12.1478173908831; Thu, 03 Nov 2016 04:51:48 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l6si7668814paz.324.2016.11.03.04.51.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Nov 2016 04:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-440287-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-440287-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-440287-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=uW4wQ8Wd2ByK2D/ndqEiiywUcW6kMh1HzHsJVBMjd1NrHqHBZ7 R5awnT/e2W4vDiLGusgeou6QyJluhtNFocP87wcHVaLtq/aPWRrgDAJE/RGkoZcj NNdKPD8expz+9dV4fEfCUdpULVRoCCpNlPUt6Xot3TzOm2F3JOl4O2agU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=WXtGriLOD6bnBczzeAyeWVctTd4=; b=TXL2p7Mz03+hfV3/zpYo hrYbAebBe5DeuuRueWoVzB7SVVlm9J5cxJxQ156yDkiZV+YN4mxtrnWlUFVgSPL1 FA1fSIIp3zFGr5pLgkesSMiwZheINwYvkVzE0+f9GtKvTmIolkM7QU0Ue++XhF3e YV9A7tH9ZWegJ+eBFCFrlas= Received: (qmail 105572 invoked by alias); 3 Nov 2016 11:51:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 105544 invoked by uid 89); 3 Nov 2016 11:51:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=judging, 7652, Testing X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Nov 2016 11:51:18 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D94FB61B93 for ; Thu, 3 Nov 2016 11:51:17 +0000 (UTC) Received: from localhost.localdomain (vpn1-5-133.ams2.redhat.com [10.36.5.133]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA3BpGjO025347 for ; Thu, 3 Nov 2016 07:51:17 -0400 To: GCC Patches From: Bernd Schmidt Subject: Change default level for -Wimplicit-fallthrough Message-ID: <2fa103b3-9389-0a5e-a253-6b96dfe61d38@redhat.com> Date: Thu, 3 Nov 2016 12:51:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 X-IsSubscribed: yes I'm concerned about the number of false positives for this warning, and judging by previous discussions, I'm not alone in this. This patch limits it to level 1 (any comment before the case label disables the warning) for cases where the user specified no explicit level. It'll still generate enough noise that people will be aware of it and can choose whether to use a higher level or not. Bootstrapped and tested on x86_64-linux. Ok? Bernd c-family/ * c.opt (Wimplicit-fallthrough=): Default to 1. gcc/ * common.opt (Wimplicit-fallthrough=): Default to 1. * doc/invoke.texi (-Wextra, -Wimplicit-fallthrough): Adjust documentation. testsuite/ * c-c++-comon/Wimplicit-fallthrough-1.c: Specify level for -Wimplicit-fallthrough * c-c++-comon/Wimplicit-fallthrough-10.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-12.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-16.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-19.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-2.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-22.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-25.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-26.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-3.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-4.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-5.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-7.c: Likewise. * c-c++-comon/Wimplicit-fallthrough-8.c: Likewise. * c-c++-comon/attr-fallthrough-1.c: Likewise. * g++.dg/cpp0x/fallthrough1.C: Likewise. * objc.dg/Wimplicit-fallthrough-1.m: Likewise. Index: gcc/c-family/c.opt =================================================================== --- gcc/c-family/c.opt (revision 241233) +++ gcc/c-family/c.opt (working copy) @@ -541,7 +541,7 @@ C ObjC Var(warn_implicit) Warning LangEn Warn about implicit declarations. Wimplicit-fallthrough= -LangEnabledBy(C ObjC C++ ObjC++,Wextra,3,0) +LangEnabledBy(C ObjC C++ ObjC++,Wextra,1,0) ; in common.opt Wdouble-promotion Index: gcc/common.opt =================================================================== --- gcc/common.opt (revision 241233) +++ gcc/common.opt (working copy) @@ -602,7 +602,7 @@ Common Var(warn_hsa) Init(1) Warning Warn when a function cannot be expanded to HSAIL. Wimplicit-fallthrough -Common Alias(Wimplicit-fallthrough=,3,0) Warning +Common Alias(Wimplicit-fallthrough=,1,0) Warning Wimplicit-fallthrough= Common Var(warn_implicit_fallthrough) RejectNegative Joined UInteger Warning Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi (revision 241233) +++ gcc/doc/invoke.texi (working copy) @@ -3735,7 +3735,7 @@ name is still supported, but the newer n @gccoptlist{-Wclobbered @gol -Wempty-body @gol -Wignored-qualifiers @gol --Wimplicit-fallthrough=3 @gol +-Wimplicit-fallthrough=1 @gol -Wmissing-field-initializers @gol -Wmissing-parameter-type @r{(C only)} @gol -Wold-style-declaration @r{(C only)} @gol @@ -4107,7 +4107,7 @@ This warning is enabled by @option{-Wall @item -Wimplicit-fallthrough @opindex Wimplicit-fallthrough @opindex Wno-implicit-fallthrough -@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3} +@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=1} and @option{-Wno-implicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=0}. Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-1.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-1.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-1.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ /* Test taken from . */ Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-10.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-10.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-10.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ extern void bar (int); Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-12.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-12.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-12.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough -O2" } */ +/* { dg-options "-Wimplicit-fallthrough=3 -O2" } */ /* Don't let optimizations preclude the warning. */ Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-16.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-16.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-16.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ /* Another nested switch, and with an initialization on top. Check that we do warn here. */ Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-19.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-19.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-19.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ /* Testing non-case labels. */ Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-2.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-2.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-2.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ extern void bar (int); Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-22.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-22.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-22.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ void bar (int); Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-25.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-25.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-25.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Wextra" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ void bar (int); Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-26.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-26.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-26.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ void bar (int); Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-3.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-3.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-3.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ extern void bar (int); Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-4.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-4.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-4.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ extern void bar (int); Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-5.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-5.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-5.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=2" } */ extern void bar (int); extern void die (void) __attribute__((noreturn)); Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-7.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-7.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-7.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ extern void bar (int); extern int bar2 (void); Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-8.c =================================================================== --- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-8.c (revision 241233) +++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-8.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ extern void grace (int); Index: gcc/testsuite/c-c++-common/attr-fallthrough-1.c =================================================================== --- gcc/testsuite/c-c++-common/attr-fallthrough-1.c (revision 241233) +++ gcc/testsuite/c-c++-common/attr-fallthrough-1.c (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wall -Wextra -Wpedantic" } */ +/* { dg-options "-Wall -Wimplicit-fallthrough=3 -Wpedantic" } */ extern void bar (int); void Index: gcc/testsuite/g++.dg/cpp0x/fallthrough1.C =================================================================== --- gcc/testsuite/g++.dg/cpp0x/fallthrough1.C (revision 241233) +++ gcc/testsuite/g++.dg/cpp0x/fallthrough1.C (working copy) @@ -1,6 +1,6 @@ // PR c/7652 // { dg-do compile { target c++11 } } -// { dg-options "-Wextra -Wall -Wpedantic" } +// { dg-options "-Wimplicit-fallthrough=3 -Wall -Wpedantic" } extern void bar (int); void Index: gcc/testsuite/objc.dg/Wimplicit-fallthrough-1.m =================================================================== --- gcc/testsuite/objc.dg/Wimplicit-fallthrough-1.m (revision 241233) +++ gcc/testsuite/objc.dg/Wimplicit-fallthrough-1.m (working copy) @@ -1,6 +1,6 @@ /* PR c/7652 */ /* { dg-do compile } */ -/* { dg-options "-Wimplicit-fallthrough" } */ +/* { dg-options "-Wimplicit-fallthrough=3" } */ /* Test taken from . */