From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71976 invoked by alias); 27 May 2015 20:51:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 71967 invoked by uid 89); 27 May 2015 20:51:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 27 May 2015 20:51:48 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 403663E493 for ; Wed, 27 May 2015 20:51:47 +0000 (UTC) Received: from [10.10.116.16] ([10.10.116.16]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4RKpkGJ012174 for ; Wed, 27 May 2015 16:51:46 -0400 Message-ID: <55662E61.4020707@redhat.com> Date: Wed, 27 May 2015 20:59:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH to handling of exception specs in system headers Content-Type: multipart/mixed; boundary="------------080601030103090806040203" X-SW-Source: 2015-05/txt/msg02569.txt.bz2 This is a multi-part message in MIME format. --------------080601030103090806040203 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 330 -pedantic shouldn't change something from OK into an error, but it was doing so for redeclaration of a declaration from a system header with a mismatched exception specification. And whether we are strict about things in system headers should be controlled by -Wsystem-headers. Tested x86_64-pc-linux-gnu, applying to trunk. --------------080601030103090806040203 Content-Type: text/x-patch; name="ped-sys.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ped-sys.patch" Content-length: 2085 commit 8c029a40a7d4348c432f09eb2512a485cfe9bda8 Author: Jason Merrill Date: Tue May 26 11:47:27 2015 -0400 * decl.c (check_redeclaration_exception_specification): Depend on -Wsystem-headers rather than -pedantic. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 420c7f40..a8cb358 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1213,14 +1213,19 @@ check_redeclaration_exception_specification (tree new_decl, all declarations, including the definition and an explicit specialization, of that function shall have an exception-specification with the same set of type-ids. */ - if ((pedantic || ! DECL_IN_SYSTEM_HEADER (old_decl)) - && ! DECL_IS_BUILTIN (old_decl) + if (! DECL_IS_BUILTIN (old_decl) && flag_exceptions && !comp_except_specs (new_exceptions, old_exceptions, ce_normal)) { - error ("declaration of %q+F has a different exception specifier", - new_decl); - inform (0, "from previous declaration %q+F", old_decl); + const char *msg + = "declaration of %q+F has a different exception specifier"; + bool complained = true; + if (! DECL_IN_SYSTEM_HEADER (old_decl)) + error (msg, new_decl); + else + complained = pedwarn (0, OPT_Wsystem_headers, msg, new_decl); + if (complained) + inform (0, "from previous declaration %q+F", old_decl); } } diff --git a/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C b/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C new file mode 100644 index 0000000..ac5c30d --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C @@ -0,0 +1,3 @@ +#include + +extern double atof (const char *); diff --git a/gcc/testsuite/g++.dg/warn/Wsystem-headers1a.C b/gcc/testsuite/g++.dg/warn/Wsystem-headers1a.C new file mode 100644 index 0000000..68f6ea1 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsystem-headers1a.C @@ -0,0 +1,6 @@ +// { dg-do compile { target *-*-*gnu } } +// { dg-options "-Wsystem-headers" } + +#include + +extern double atof (const char *); // { dg-warning "different exception spec" } --------------080601030103090806040203--