From patchwork Thu Mar 31 16:40:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 604214 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qbVdB1SY1z9sBg for ; Fri, 1 Apr 2016 03:41:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=tXAXzl2i; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=ilLTwOxa7VwmcR6EF pWKOpCFPcnWN9t1m5QFjgn0fL7/KuMt1VHOfhOnoZDdpuP82URjM23RISUkYLpsQ +rYJ0IpVWMM2UbiYqPYPbLOIlTeVuG3qiYpLluH5SSN+tCjE2hbUT+MDi6VzOqXe FROZMKKI4luLvP5x0BM7SWMsM8= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=IuQEMmj/yQjI/L0B17PBuSh 9q08=; b=tXAXzl2idFAgh4q/bohHQXHFZxwRwsYsfjyc2LxIg7e3UbQ38VzdMIB XlRoKOck2bHTNV9gbehkG0mthhWw8F+CDFneEJUmXa3f+8X0eFpWjyYmXXT73XmD yU3kNeXLURIs+Bmq6YgnHllT8Y7Yi2Ini3+S7ZrTrzRATC3DXJ1Y= Received: (qmail 18514 invoked by alias); 31 Mar 2016 16:40:49 -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 18460 invoked by uid 89); 31 Mar 2016 16:40:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=traits, DECL_IS_BUILTIN, sk:excepti, sk:comp_e X-HELO: mail-qg0-f42.google.com Received: from mail-qg0-f42.google.com (HELO mail-qg0-f42.google.com) (209.85.192.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 31 Mar 2016 16:40:39 +0000 Received: by mail-qg0-f42.google.com with SMTP id n34so61500881qge.1 for ; Thu, 31 Mar 2016 09:40:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to; bh=4NHA3X9hRDENOV56UnqKJbhykbnXea+AcWZw8TUvL94=; b=HGu8RM8nMFLiXCQDPlTHmLh7jTQS8YL4zIn6CXn1sAVJlo0ccqbILG0Pb52qN8RlDd mFw1koN99GrFCB8THQ+FWuXyFUCeKav7s4LSXoxNboekklXhw8YYoDbQzkATQkfeAURo o0+Nv7Ib4d/YURTRGbCztbV6tFHtHsfSUgkVG4b79YVXo2oJfYnQrT2YMUdcz8TIxtSy 44gRB/hcJZhzzdKeV//e7y9g83S+HdlW7XC9HCZoHYAV8p7G7OT3QS8K9BCh+Y5w4FdS 6siHoTzk4X4+SjtxvxFJJzZZ2tigLAO5QMR5AF9GZj/2QSD9CVG7SxEjhSVC6hxe8Dby 9reQ== X-Gm-Message-State: AD7BkJJx+3k5iIqzx9TZfaN37rLCdbVO0Q8R8XVc9/aY8rqgDQ0A6Uu6YGyjs5+/bRT6ow== X-Received: by 10.140.93.79 with SMTP id c73mr17402854qge.101.1459442436912; Thu, 31 Mar 2016 09:40:36 -0700 (PDT) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id v74sm4240592qkl.36.2016.03.31.09.40.35 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2016 09:40:36 -0700 (PDT) Subject: Re: [c++/68475] ICE with fno-exceptions To: Jason Merrill References: <56FBC1E3.50607@acm.org> <56FBD831.6000808@redhat.com> Cc: GCC Patches From: Nathan Sidwell Message-ID: <56FD5303.7000607@acm.org> Date: Thu, 31 Mar 2016 12:40:35 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <56FBD831.6000808@redhat.com> On 03/30/16 09:44, Jason Merrill wrote: > Hmm, I think the use of the flag there was meant to allow leaving the exception > specification off in some declarations. I'm open to getting stricter, but I'd > prefer to make it a pedwarn when !flag_exceptions rather than an error, in which > case we still need to deal with the mismatch in merge_exception_specifiers. ok. Like this? nathan 2016-03-31 Nathan Sidwell PR c++/68475 * decl.c (check_redeclaration_exception_specification): Check regardless of -fno-exceptions. * typeck2.c (merge_exception_specifiers): Relax assert by checking flag_exceptions too. PR c++/68475 * g++.dg/g++.dg/cpp0x/noexcept29.C: New. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 234641) +++ cp/decl.c (working copy) @@ -1202,16 +1202,19 @@ check_redeclaration_exception_specificat specialization, of that function shall have an exception-specification with the same set of type-ids. */ if (! DECL_IS_BUILTIN (old_decl) - && flag_exceptions && !comp_except_specs (new_exceptions, old_exceptions, ce_normal)) { 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 + if (DECL_IN_SYSTEM_HEADER (old_decl)) complained = pedwarn (0, OPT_Wsystem_headers, msg, new_decl); + else if (!flag_exceptions) + /* We used to silently permit mismatched eh specs with + -fno-exceptions, so make them a pedwarn now. */ + complained = pedwarn (0, OPT_Wpedantic, msg, new_decl); + else + error (msg, new_decl); if (complained) inform (0, "from previous declaration %q+F", old_decl); } Index: cp/typeck2.c =================================================================== --- cp/typeck2.c (revision 234641) +++ cp/typeck2.c (working copy) @@ -2143,7 +2143,7 @@ merge_exception_specifiers (tree list, t return add; noex = TREE_PURPOSE (list); gcc_checking_assert (!TREE_PURPOSE (add) - || errorcount + || errorcount || !flag_exceptions || cp_tree_equal (noex, TREE_PURPOSE (add))); /* Combine the dynamic-exception-specifiers, if any. */ Index: testsuite/g++.dg/cpp0x/noexcept29.C =================================================================== --- testsuite/g++.dg/cpp0x/noexcept29.C (nonexistent) +++ testsuite/g++.dg/cpp0x/noexcept29.C (working copy) @@ -0,0 +1,19 @@ +// { dg-do compile { target c++11 } } +// { dg-additional-options "-fno-exceptions" } + +// PR68475 we used to not check eh spec matching with -fno-exceptions, +// but this could lead to ICEs. + +template struct traits; + +template struct X +{ + void Foo () noexcept (traits ::foo ()); // { dg-message "previous declaration" } +}; + +template +void +X::Foo () noexcept (traits ::bar ()) // { dg-error "different exception specifier" } +{ +} +