From patchwork Tue Mar 9 15:23:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1449939 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=i/0nycjf; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DvzWD25gVz9sS8 for ; Wed, 10 Mar 2021 02:23:36 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 342523959C1C; Tue, 9 Mar 2021 15:23:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 342523959C1C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1615303407; bh=5qwghtdhue3P8VK5BzYORfZkUOLYppdHo8YXP6FfrGY=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=i/0nycjfcI1qKyN3p0H7AFg7rkQ+p78Hjf+VAY4xgwigwfqFzd2+baZGhLRVsHLs7 uen4RTNkt+yD92M/SYxGx1BQv47RAufk+7SuKtsDy24W0HnuzyakolcWLjjt5NEnx1 PqmAi8Ovep+cOipxyZC4zc4XTT/rrF1QoqhbfKWg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 3AB8B39574D5 for ; Tue, 9 Mar 2021 15:23:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3AB8B39574D5 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-372-7mrowryaMCq5j5NNDr_r_g-1; Tue, 09 Mar 2021 10:23:21 -0500 X-MC-Unique: 7mrowryaMCq5j5NNDr_r_g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46FA180432E; Tue, 9 Mar 2021 15:23:20 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-238.ams2.redhat.com [10.36.113.238]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D41B860C13; Tue, 9 Mar 2021 15:23:19 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 129FNH882901995 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 9 Mar 2021 16:23:17 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 129FNFWB2901994; Tue, 9 Mar 2021 16:23:15 +0100 Date: Tue, 9 Mar 2021 16:23:15 +0100 To: Nathan Sidwell Subject: [PATCH] c++, v2: Fix coroutines on targetm.cxx.cdtor_return_this targets [PR99459] Message-ID: <20210309152315.GP745611@tucnak> References: <20210309095158.GL745611@tucnak> <8f407ed8-7d7c-6fc2-f43d-eb9a06e37a68@acm.org> MIME-Version: 1.0 In-Reply-To: <8f407ed8-7d7c-6fc2-f43d-eb9a06e37a68@acm.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org, Iain Sandoe Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" On Tue, Mar 09, 2021 at 08:01:26AM -0500, Nathan Sidwell wrote: > thanks for digging into this. Looks good, but could you take the > opportunity to rewrite the conditionals to a single > > if (dummy) { ... do the non-null things ... } > > ? So like this? Bootstrapped/regtested on x86_64-linux and i686-linux. 2021-03-09 Jakub Jelinek PR c++/99459 * coroutines.cc (build_co_await): Look through NOP_EXPRs in build_special_member_call return value to find the CALL_EXPR. Simplify. Jakub --- gcc/cp/coroutines.cc.jj 2021-03-08 14:46:26.845072273 +0100 +++ gcc/cp/coroutines.cc 2021-03-09 14:26:19.867411700 +0100 @@ -863,16 +863,17 @@ build_co_await (location_t loc, tree a, final awaiter, so check for a non-throwing DTOR where needed. */ tree a_type = TREE_TYPE (a); if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (a_type)) - { - tree dummy + if (tree dummy = build_special_member_call (a, complete_dtor_identifier, NULL, a_type, LOOKUP_NORMAL, - tf_none); - dummy = dummy ? TREE_OPERAND (CALL_EXPR_FN (dummy), 0) - : NULL_TREE; - if (dummy && coro_diagnose_throwing_fn (dummy)) - return error_mark_node; - } + tf_none)) + { + if (CONVERT_EXPR_P (dummy)) + dummy = TREE_OPERAND (dummy, 0); + dummy = TREE_OPERAND (CALL_EXPR_FN (dummy), 0); + if (coro_diagnose_throwing_fn (dummy)) + return error_mark_node; + } } } else @@ -1026,16 +1027,17 @@ build_co_await (location_t loc, tree a, if (coro_diagnose_throwing_fn (awrs_func)) return error_mark_node; if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (o_type)) - { - tree dummy + if (tree dummy = build_special_member_call (e_proxy, complete_dtor_identifier, NULL, o_type, LOOKUP_NORMAL, - tf_none); - dummy = dummy ? TREE_OPERAND (CALL_EXPR_FN (dummy), 0) - : NULL_TREE; - if (dummy && coro_diagnose_throwing_fn (dummy)) - return error_mark_node; - } + tf_none)) + { + if (CONVERT_EXPR_P (dummy)) + dummy = TREE_OPERAND (dummy, 0); + dummy = TREE_OPERAND (CALL_EXPR_FN (dummy), 0); + if (coro_diagnose_throwing_fn (dummy)) + return error_mark_node; + } } /* We now have three call expressions, in terms of the promise, handle and