From patchwork Fri Sep 6 09:43:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 273130 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 6D6EA2C00D1 for ; Fri, 6 Sep 2013 19:44:37 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=g7t4BOhpBK3ClwsEq K8KDspGbcqzFjxpecR98b7GfOLN1ckM/CgV/Y45iRc8jLZ0U0ETO3vAOrhLOPfg6 QAlHh0bN3yP5+SF4HL2r5vEnNSOwLXwnhitDxua/3cWtwUp97too3PUyb/RDtVz9 cbGQfhp2t6OW3RLLVxK54SQrNI= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=PuQLDi6iOEM/QA6QC4nfoVM K3hs=; b=tijFgmRNHN0OjuMIv7VHMuuGmWgkqkCPO6kN5QQATjN9HF0qBjrINuZ W+a7Y2/6K7h3Sko8MeC22GbOh8exDgXfKtqboamqMpsGgQCUK1uSWseDp6aIliYw 0Do/J0IcVemwXamEz7OBarITvQGTDYUY7C0yvlg1H6uE9d9RDSLM= Received: (qmail 26288 invoked by alias); 6 Sep 2013 09:44:31 -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 26276 invoked by uid 89); 6 Sep 2013 09:44:31 -0000 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Sep 2013 09:44:31 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RDNS_NONE, SPF_HELO_FAIL autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1VHsa8-0006NA-C0 from Tom_deVries@mentor.com ; Fri, 06 Sep 2013 02:44:00 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 6 Sep 2013 02:43:59 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Fri, 6 Sep 2013 10:43:57 +0100 Message-ID: <5229A3D6.1060609@mentor.com> Date: Fri, 6 Sep 2013 11:43:50 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 MIME-Version: 1.0 To: Jason Merrill CC: "gcc-patches@gcc.gnu.org" , Torvald Riegel Subject: Re: [PATCH, C++, PR58282] Handle noexcept on transactions with -fno-exceptions References: <5225B3E7.8080408@mentor.com> <52276C0A.5060603@redhat.com> In-Reply-To: <52276C0A.5060603@redhat.com> On 04/09/13 19:21, Jason Merrill wrote: > On 09/03/2013 06:03 AM, Tom de Vries wrote: >> * semantics.c (finish_transaction_stmt, build_transaction_expr): Handle >> flag_exceptions. > > I'd rather handle this at a lower level, by making > build_must_not_throw_expr return its argument if -fno-exceptions. > Jason, This patch implements that way of fixing. In addition, it adds a test-case. Bootstrapped and reg-tested on x86_64. OK for trunk? Thanks, - Tom 2013-09-02 Tom de Vries PR c++/58282 * except.c (build_must_not_throw_expr): Handle flag_exceptions. * g++.dg/tm/noexcept-6.C: New test. diff --git a/gcc/cp/except.c b/gcc/cp/except.c index fbebcba..c76d944 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -374,6 +374,9 @@ build_must_not_throw_expr (tree body, tree cond) { tree type = body ? TREE_TYPE (body) : void_type_node; + if (!flag_exceptions) + return body; + if (cond && !value_dependent_expression_p (cond)) { cond = cxx_constant_value (cond); diff --git a/gcc/testsuite/g++.dg/tm/noexcept-6.C b/gcc/testsuite/g++.dg/tm/noexcept-6.C new file mode 100644 index 0000000..4391159 --- /dev/null +++ b/gcc/testsuite/g++.dg/tm/noexcept-6.C @@ -0,0 +1,23 @@ +// { dg-do compile } +// { dg-options "-fno-exceptions -fgnu-tm -O -std=c++0x -fdump-tree-tmlower" } + +struct TrueFalse +{ + static constexpr bool v() { return true; } +}; + +int global; + +template int foo() +{ + return __transaction_atomic noexcept(T::v()) (global + 1); +} + +int f1() +{ + return foo(); +} + +/* { dg-final { scan-tree-dump-times "eh_must_not_throw" 0 "tmlower" } } */ +/* { dg-final { scan-tree-dump-times "__transaction_atomic" 1 "tmlower" } } */ +/* { dg-final { cleanup-tree-dump "tmlower" } } */