From patchwork Tue Oct 11 21:58:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2313515wrs; Tue, 11 Oct 2022 14:59:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62b6mM2AK3RsP4RkddDAGhUkWc1LO/prJ6cgx9wgjX0Jt8t4G1SbW2IeCFp9KrZy/KdZw+ X-Received: by 2002:a05:6402:1a33:b0:458:a00a:80a with SMTP id be19-20020a0564021a3300b00458a00a080amr25329222edb.378.1665525568165; Tue, 11 Oct 2022 14:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665525568; cv=none; d=google.com; s=arc-20160816; b=ezA4RutTy2fX9BL989LeNUZT46MuHHlMU8HiM7k1VLyLJQIAaGRewuedzAe7W4JLey 17WisCGgyG0cqcQP8MUHytpeFvv1InpIUJQsHMj5Ntbh8M5ThNYDRZK4TQd7sveA6Zjm Oy4Qv/xbsIzo5trimbdu+psHqYxkPOJSGLemMCKbhJjbJObT/mYlsT/hy/TbskHmICUc l3s3HjXQvCXXNAMl3BxCQnNpxCNT3siw/coqbW0fIBPSsLwq7/kcatu78COQ7G+Jh1B2 vQMKR8UO8r1gVU0TjOsZH46Mpcw7hRLVixmw6c2PuxuTLYVkrJmADi6SxqbOnjqnNKhp 8qDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=6ip14ywThZf8WT4zgcTDZvDA32TxLpys2dMkqRhIBy4=; b=Ak/8wVqAOadR2kuv3lG1O8+PEQD5uIQ4d7IvInOirF5ZmLC+Zi09Uy+8iolGCo0QVf L0IX2hiFON6t7s1kubTUNg/dY/qAeSfFS4RSNZOFUqsi5agL4s/lFPJwd0/h+Rrge1/9 SuWD0czkokg4niyD8HJ4g0gbZ+IFUG7dbjjIEQjueLEApInZKGidoZn91rbGnB9Hs62V ipbSFnDZGquNgwRdioEdE1Gakq3YW9s5ysAHqhoDCojeF7AGkBql3VNFR+31jvekogdF a3zrzNHdU3vcS0RiGpYtnXs3j56o3C0AODsULLow2XnvkkFcE2ulkmZdLuydYuz/ez8s P9LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OivcfI5O; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id s1-20020a170906960100b007416e100f3dsi11418779ejx.986.2022.10.11.14.59.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 14:59:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OivcfI5O; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 23E7C385E036 for ; Tue, 11 Oct 2022 21:59:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23E7C385E036 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665525567; bh=6ip14ywThZf8WT4zgcTDZvDA32TxLpys2dMkqRhIBy4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=OivcfI5O/i6/bfsvkrQWAyqEamBOvV/eukf7/soyhfyKfIRZneQqIf5IwJwZuHMus yz1L+JUr0rYxeczZL46MaTDNrxEu+vDApXEBF5jX0DwMY58eZLHoP2B0IeyZAoV6zg 85HC/H3g7DMOoVXrEJeAsmiSxji/pM5Rgm82t7/Q= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 21483385415D for ; Tue, 11 Oct 2022 21:58:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 21483385415D Received: by mail-wr1-x42d.google.com with SMTP id r13so23565671wrj.11 for ; Tue, 11 Oct 2022 14:58:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6ip14ywThZf8WT4zgcTDZvDA32TxLpys2dMkqRhIBy4=; b=y2eEZOdYa5c4J+CM3ep7ryMNqLQEjl572RBogJPtk8TA2oyNNS+6c0ON+IuIhyeyxz S+zJHwmfZq6O1I1R/7D89WWM1PjRSiNgEwYP5hdGciXRFVLDTbbNirw/WkMclcWFn+ix 6QytuvXqqVugbylrVAUDkokAliXM77hordpLpPTIQLdsqR8MFzNmtbgtIvz2sj1ChG9e kVYG9FVPY0qSKitpTH+pSLRA0vjcGfvG9PvCXHfl/K6esVEseOLgppCnVxUma3CM0H4q HOSqptucKTYzOnWIH3EL8lEQ8zeVlJqYmcFQhuRZWLE6zX2KvJMm9GNkM+ot41HP9eMR jh1Q== X-Gm-Message-State: ACrzQf3fiZNy3kv0L8pZIbgU6uCa9vgg6nFDZbCgB5Ve1KwwfoUUwoQu LNdj4yM6PjBrk/txU18ODbvHJebQzw8= X-Received: by 2002:a5d:47a8:0:b0:231:ca77:ac57 with SMTP id 8-20020a5d47a8000000b00231ca77ac57mr1545806wrb.384.1665525522450; Tue, 11 Oct 2022 14:58:42 -0700 (PDT) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id o9-20020a05600c510900b003a540fef440sm188274wms.1.2022.10.11.14.58.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Oct 2022 14:58:41 -0700 (PDT) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [PATCH] coroutines: Use cp_build_init_expr consistently. Date: Tue, 11 Oct 2022 22:58:31 +0100 Message-Id: <20221011215831.67154-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Iain Sandoe via Gcc-patches From: Iain Sandoe Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746430138143679067?= X-GMAIL-MSGID: =?utf-8?q?1746430138143679067?= Tested on x86_64-darwin19, OK for master? thanks Iain -- >8 -- Now we have the TARGET_EXPR_ELIDING_P flag, it is important to ensure it is set properly on target exprs. The code here has a mixture of APIs used to build inits. This patch changes that to use cp_build_init_expr() where possible, since that handles setting the flag. --- gcc/cp/coroutines.cc | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 01a3e831ee5..20d309445eb 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -1025,8 +1025,7 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind) else { e_proxy = get_awaitable_var (suspend_kind, o_type); - o = cp_build_modify_expr (loc, e_proxy, INIT_EXPR, o, - tf_warning_or_error); + o = cp_build_init_expr (loc, e_proxy, o); } /* I suppose we could check that this is contextually convertible to bool. */ @@ -2889,8 +2888,7 @@ flatten_await_stmt (var_nest_node *n, hash_set *promoted, gcc_checking_assert (!already_present); tree inner = TREE_OPERAND (init, 1); gcc_checking_assert (TREE_CODE (inner) != COND_EXPR); - init = cp_build_modify_expr (input_location, var, INIT_EXPR, init, - tf_warning_or_error); + init = cp_build_init_expr (var, init); /* Simplify for the case that we have an init containing the temp alone. */ if (t == n->init && n->var == NULL_TREE) @@ -3656,8 +3654,7 @@ await_statement_walker (tree *stmt, int *do_subtree, void *d) if (TREE_CODE (cond_inner) == CLEANUP_POINT_EXPR) cond_inner = TREE_OPERAND (cond_inner, 0); location_t sloc = EXPR_LOCATION (SWITCH_STMT_COND (sw_stmt)); - tree new_s = cp_build_init_expr (sloc, newvar, - cond_inner); + tree new_s = cp_build_init_expr (sloc, newvar, cond_inner); finish_expr_stmt (new_s); SWITCH_STMT_COND (sw_stmt) = newvar; /* Now add the switch statement with the condition re- @@ -4902,9 +4899,8 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) if (flag_exceptions) { /* This var is now live. */ - r = build_modify_expr (fn_start, parm.guard_var, - boolean_type_node, INIT_EXPR, fn_start, - boolean_true_node, boolean_type_node); + r = cp_build_init_expr (fn_start, parm.guard_var, + boolean_true_node); finish_expr_stmt (r); } } @@ -4948,9 +4944,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) r = coro_build_cvt_void_expr_stmt (r, fn_start); finish_expr_stmt (r); - r = build_modify_expr (fn_start, coro_promise_live, boolean_type_node, - INIT_EXPR, fn_start, boolean_true_node, - boolean_type_node); + r = cp_build_init_expr (fn_start, coro_promise_live, boolean_true_node); finish_expr_stmt (r); promise_dtor @@ -5031,8 +5025,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) NULL_TREE); add_decl_expr (gro); gro_bind_vars = gro; - r = cp_build_modify_expr (input_location, gro, INIT_EXPR, get_ro, - tf_warning_or_error); + r = cp_build_init_expr (gro, get_ro); /* The constructed object might require a cleanup. */ if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (gro_type)) { @@ -5053,9 +5046,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) cleanup. */ if (gro_ret_dtor) { - r = build_modify_expr (fn_start, coro_gro_live, boolean_type_node, - INIT_EXPR, fn_start, boolean_true_node, - boolean_type_node); + r = cp_build_init_expr (fn_start, coro_gro_live, boolean_true_node); finish_expr_stmt (r); } /* Initialize the resume_idx_var to 0, meaning "not started". */