From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id AE98539F843A for ; Thu, 5 Nov 2020 23:26:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AE98539F843A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-286-xObiQbLmNhCrCbvJulz6Nw-1; Thu, 05 Nov 2020 18:26:09 -0500 X-MC-Unique: xObiQbLmNhCrCbvJulz6Nw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73AD81868400 for ; Thu, 5 Nov 2020 23:26:08 +0000 (UTC) Received: from redhat.com (ovpn-119-110.rdu2.redhat.com [10.10.119.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E23531A3D7; Thu, 5 Nov 2020 23:26:07 +0000 (UTC) Date: Thu, 5 Nov 2020 18:26:05 -0500 From: Marek Polacek To: David Malcolm Cc: GCC Patches , Jason Merrill Subject: Re: [PATCH] c++: Add -Wexceptions warning option [PR97675] Message-ID: <20201105232605.GB3982@redhat.com> References: <20201105160318.107397-1-polacek@redhat.com> <42878a70b164a5a67ac9f3456ec1adbe25e315e9.camel@redhat.com> MIME-Version: 1.0 In-Reply-To: <42878a70b164a5a67ac9f3456ec1adbe25e315e9.camel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Nov 2020 23:26:13 -0000 On Thu, Nov 05, 2020 at 06:13:41PM -0500, David Malcolm via Gcc-patches wrote: > On Thu, 2020-11-05 at 11:03 -0500, Marek Polacek via Gcc-patches wrote: > > This PR asks that we add a warning option for an existing (very old) > > warning, so that it can be disabled selectively. clang++ uses > > -Wexceptions for this, so I added this new option rather than using > > e.g. -Wnoexcept. > > > > gcc/c-family/ChangeLog: > > > > PR c++/97675 > > * c.opt (Wexceptions): New option. > > > > gcc/cp/ChangeLog: > > > > PR c++/97675 > > * except.c (check_handlers_1): Use OPT_Wexceptions for the > > warning. Use inform for the second part of the warning. > > > > gcc/ChangeLog: > > > > PR c++/97675 > > * doc/invoke.texi: Document -Wexceptions. > > > > gcc/testsuite/ChangeLog: > > > > PR c++/97675 > > * g++.old-deja/g++.eh/catch10.C: Adjust dg-warning. > > * g++.dg/warn/Wexceptions1.C: New test. > > * g++.dg/warn/Wexceptions2.C: New test. > > --- > > gcc/c-family/c.opt | 4 ++++ > > gcc/cp/except.c | 9 ++++----- > > gcc/doc/invoke.texi | 8 +++++++- > > gcc/testsuite/g++.dg/warn/Wexceptions1.C | 9 +++++++++ > > gcc/testsuite/g++.dg/warn/Wexceptions2.C | 10 ++++++++++ > > gcc/testsuite/g++.old-deja/g++.eh/catch10.C | 4 ++-- > > 6 files changed, 36 insertions(+), 8 deletions(-) > > create mode 100644 gcc/testsuite/g++.dg/warn/Wexceptions1.C > > create mode 100644 gcc/testsuite/g++.dg/warn/Wexceptions2.C > > > > diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt > > index 426636be839..9493acb82ff 100644 > > --- a/gcc/c-family/c.opt > > +++ b/gcc/c-family/c.opt > > @@ -579,6 +579,10 @@ Werror-implicit-function-declaration > > C ObjC RejectNegative Warning Alias(Werror=, implicit-function- > > declaration) > > This switch is deprecated; use -Werror=implicit-function-declaration > > instead. > > > > +Wexceptions > > +C++ ObjC++ Var(warn_exceptions) Init(1) > > +Warn when an exception handler is shadowed by another handler. > > + > > Wextra > > C ObjC C++ ObjC++ Warning > > ; in common.opt > > diff --git a/gcc/cp/except.c b/gcc/cp/except.c > > index cb1a4105dae..985206f6a64 100644 > > --- a/gcc/cp/except.c > > +++ b/gcc/cp/except.c > > @@ -975,11 +975,10 @@ check_handlers_1 (tree master, > > tree_stmt_iterator i) > > tree handler = tsi_stmt (i); > > if (TREE_TYPE (handler) && can_convert_eh (type, TREE_TYPE > > (handler))) > > { > > Can you add an auto_diagnostic_group here please. Yup, I've pushed this: >From 44e1f63e20fec07e3a10d8e75336cfda64c911bf Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 5 Nov 2020 18:23:56 -0500 Subject: [pushed] c++: Add auto_diagnostic_group to check_handlers_1. This was missing. gcc/cp/ChangeLog: * except.c (check_handlers_1): Add auto_diagnostic_group. --- gcc/cp/except.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 985206f6a64..b72a28c1aa9 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -975,6 +975,7 @@ check_handlers_1 (tree master, tree_stmt_iterator i) tree handler = tsi_stmt (i); if (TREE_TYPE (handler) && can_convert_eh (type, TREE_TYPE (handler))) { + auto_diagnostic_group d; if (warning_at (EXPR_LOCATION (handler), OPT_Wexceptions, "exception of type %qT will be caught by earlier " "handler", TREE_TYPE (handler))) base-commit: e6fd02cc6d874c523466250a1cb724e0c7af9d75 -- 2.28.0