From patchwork Tue Feb 21 12:01:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 60019 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1837391wrn; Tue, 21 Feb 2023 04:38:08 -0800 (PST) X-Google-Smtp-Source: AK7set+uaQLFvCHQOonsq8UCBsTybkCB1E4vJ5x401p6IGpMyKjCwHODQ5+zP5wE6GdxLVM8isu1 X-Received: by 2002:a17:906:4fd2:b0:8d9:c3d:91d8 with SMTP id i18-20020a1709064fd200b008d90c3d91d8mr6237447ejw.31.1676983088357; Tue, 21 Feb 2023 04:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676983088; cv=none; d=google.com; s=arc-20160816; b=RtVZuzqNhyLLPysP3zWP5u5cL/fL8rphCrwtnJwmD45zuZphP9t6Nefkbakk08SYY7 A24iitqd9tFKUkb7EDRrZKAN6MAy2uT3LcBT4y2HwBqKwBdS+oo114weRrLPt0GRo3gT mSQII5IwDNyG1SUkCht2kVqoE3+xYLZpRE4v9vNI5ka2WvoPMcLF/Jb0mp8osj+Hi2+M ftZuBTJ5wmHOWOCb1rA81Cqmnxl6/ia+VQNlphBAPh7Vbv0NHKL/S2XXVONpE25FuNnq uuzNzl/ZcK/44UvFtIEHvbCoUwDb1dTucvdT+UruoZr1b+llooiknhjpsn+BH2MpltGF uqYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dmarc-filter :delivered-to; bh=xb1CCtsf/kMc5yfrZoQf4CdA00LJzqPiyDi4OxFeit8=; b=uQ+IfM8CHiJFSUXPmpo/Dyb8EiPIV/ZY2hFVWRpEdjDW85tgnNToE6Fyy7QcnAwiy2 wwpkyGLhAq9o4/HrXQLl+bTcN/X0QzxTfsfg1en7VpFvLl3StvItXwC9SeO9MlLi3WM5 rP/N/BX82pngVAsIjxf8cJ10TxugFcl0Y4peIzoIkmNhQ5QLbM3KTGKbsl8xvQ6PsI/u 6/d6+ctOhfQQdSFS9EfTVkl+1r3DsN0hH8F9h/ulTeR3BDrA3xDbdos0e6/hYzrq/Y7x /qkBvvnYkOfi/17/8+9Rfe++FNIAa6ZVHS0+NxFn4RdOsmOWYBvRLTdbhWyGCWKhC44E J7Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=g5JaUl5Y; 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" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 26-20020a170906029a00b008d17b125784si8399702ejf.30.2023.02.21.04.38.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:38:08 -0800 (PST) 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=@embecosm.com header.s=google header.b=g5JaUl5Y; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 66D12397A1C6 for ; Tue, 21 Feb 2023 12:13:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id C4B203846902 for ; Tue, 21 Feb 2023 12:04:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4B203846902 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x431.google.com with SMTP id z8so3884423wrm.8 for ; Tue, 21 Feb 2023 04:04:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=xb1CCtsf/kMc5yfrZoQf4CdA00LJzqPiyDi4OxFeit8=; b=g5JaUl5YN8jL+90q2a4XL5OpUZ3s2ygkRznLPYU931xFdkO1bluh7Go10btyCxmZRl kS1eiquVxM0FhHsr7W/urO9jUfpNZrW2a9BM8XKQr+xEwWzjB8eeFxloPcC1ofNMfYCK a/04vDr5tPgOvpa3ElNbXTgrHMYb5ENuiqH7B6xzbT3nBMVev/jHC1BEp9NYTMC9kBCD sQeFDIkpJkNfU+o1PWteuE8e5YJl72F75pnT5JTGDMCX+9DEGS+cpccZ32+UckJDoePe qj9q4QPheSX7JmBqdIFiz/tlPk8QHaS7GNswuWU4TzejcJGu25qUCAaf7Rex7SW1SyvY KKdw== 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:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xb1CCtsf/kMc5yfrZoQf4CdA00LJzqPiyDi4OxFeit8=; b=AATNK9B2QVQvsT2cyRxJt5PDdd4+esWjuSOnjg4D3Zz/AVac3MXk4+F82XSfgm3NJ6 FxrZtVBQETEoEV/72pH9PYE3UyQ6XNzNi1msaGp3GXtA/bhbRHwiy+J0qy3QoDW0VAMh CFAp1ddEd3V5yDd9hL7sVzNRStSWPMp+HISyvzoMV0xJ74ufQQ3tMxvxo34iaV01EYP4 T2h1bKM2dl6oEi6NUOkFjA3SXWChOU54hlfMMzuKZZlZtTPG1pOwHhBAogCQ1oDBad44 CTjqrVFbgoqQN6LhD8k242bK6UpK1b0QYqeC8qaSxp2RBELjJ3D6MzaMYeZUUcZ7kArO fMWQ== X-Gm-Message-State: AO0yUKXDjh4eIgRB2aXp/CMzqpwboZxeMsFW02A3GK/+sw4Swr4VXN9y rFFJQ9dQiNKY4LU/fEFlksLix3aYCnNvGP+XrQ== X-Received: by 2002:a05:6000:1052:b0:2c5:582b:bad1 with SMTP id c18-20020a056000105200b002c5582bbad1mr4392313wrx.30.1676981050891; Tue, 21 Feb 2023 04:04:10 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:04:10 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [committed 059/103] gccrs: constexpr: Add `rust_sorry_at` in places relying on init values Date: Tue, 21 Feb 2023 13:01:49 +0100 Message-Id: <20230221120230.596966-60-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221120230.596966-1-arthur.cohen@embecosm.com> References: <20230221120230.596966-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: , Reply-To: arthur.cohen@embecosm.com 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?1758444219071423574?= X-GMAIL-MSGID: =?utf-8?q?1758444219071423574?= From: Arthur Cohen gcc/rust/ChangeLog: * backend/rust-constexpr.cc (build_anon_member_initialization): Workaround uninitialized values. (build_data_member_initialization): Likewise. --- gcc/rust/backend/rust-constexpr.cc | 96 +++++++++++++++--------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc index 8623816236c..23d940d04ce 100644 --- a/gcc/rust/backend/rust-constexpr.cc +++ b/gcc/rust/backend/rust-constexpr.cc @@ -3658,49 +3658,48 @@ eval_call_expression (const constexpr_ctx *ctx, tree t, bool lval, whose constructor we are processing. Add the initializer to the vector and return true to indicate success. */ -static bool -build_anon_member_initialization (tree member, tree init, - vec **vec_outer) -{ - /* MEMBER presents the relevant fields from the inside out, but we need - to build up the initializer from the outside in so that we can reuse - previously built CONSTRUCTORs if this is, say, the second field in an - anonymous struct. So we use a vec as a stack. */ - auto_vec fields; - do - { - fields.safe_push (TREE_OPERAND (member, 1)); - member = TREE_OPERAND (member, 0); - } - while (ANON_AGGR_TYPE_P (TREE_TYPE (member)) - && TREE_CODE (member) == COMPONENT_REF); - - /* VEC has the constructor elements vector for the context of FIELD. - If FIELD is an anonymous aggregate, we will push inside it. */ - vec **vec = vec_outer; - tree field; - while (field = fields.pop (), ANON_AGGR_TYPE_P (TREE_TYPE (field))) - { - tree ctor; - /* If there is already an outer constructor entry for the anonymous - aggregate FIELD, use it; otherwise, insert one. */ - if (vec_safe_is_empty (*vec) || (*vec)->last ().index != field) - { - ctor = build_constructor (TREE_TYPE (field), NULL); - CONSTRUCTOR_APPEND_ELT (*vec, field, ctor); - } - else - ctor = (*vec)->last ().value; - vec = &CONSTRUCTOR_ELTS (ctor); - } - - /* Now we're at the innermost field, the one that isn't an anonymous - aggregate. Add its initializer to the CONSTRUCTOR and we're done. */ - gcc_assert (fields.is_empty ()); - CONSTRUCTOR_APPEND_ELT (*vec, field, init); - - return true; -} +// static bool +// build_anon_member_initialization (tree member, tree init, +// vec **vec_outer) +// { +// /* MEMBER presents the relevant fields from the inside out, but we need +// to build up the initializer from the outside in so that we can reuse +// previously built CONSTRUCTORs if this is, say, the second field in an +// anonymous struct. So we use a vec as a stack. */ +// auto_vec fields; +// do +// { +// fields.safe_push (TREE_OPERAND (member, 1)); +// member = TREE_OPERAND (member, 0); +// } while (ANON_AGGR_TYPE_P (TREE_TYPE (member)) +// && TREE_CODE (member) == COMPONENT_REF); +// +// /* VEC has the constructor elements vector for the context of FIELD. +// If FIELD is an anonymous aggregate, we will push inside it. */ +// vec **vec = vec_outer; +// tree field; +// while (field = fields.pop (), ANON_AGGR_TYPE_P (TREE_TYPE (field))) +// { +// tree ctor; +// /* If there is already an outer constructor entry for the anonymous +// aggregate FIELD, use it; otherwise, insert one. */ +// if (vec_safe_is_empty (*vec) || (*vec)->last ().index != field) +// { +// ctor = build_constructor (TREE_TYPE (field), NULL); +// CONSTRUCTOR_APPEND_ELT (*vec, field, ctor); +// } +// else +// ctor = (*vec)->last ().value; +// vec = &CONSTRUCTOR_ELTS (ctor); +// } +// +// /* Now we're at the innermost field, the one that isn't an anonymous +// aggregate. Add its initializer to the CONSTRUCTOR and we're done. */ +// gcc_assert (fields.is_empty ()); +// CONSTRUCTOR_APPEND_ELT (*vec, field, init); +// +// return true; +// } ///* V is a vector of constructor elements built up for the base and member // initializers of a constructor for TYPE. They need to be in increasing @@ -3750,7 +3749,7 @@ build_anon_member_initialization (tree member, tree init, static bool build_data_member_initialization (tree t, vec **vec) { - tree member, init; + tree member; if (TREE_CODE (t) == CLEANUP_POINT_EXPR) t = TREE_OPERAND (t, 0); if (TREE_CODE (t) == EXPR_STMT) @@ -3835,7 +3834,8 @@ build_data_member_initialization (tree t, vec **vec) member = TREE_OPERAND (member, 1); else if (ANON_AGGR_TYPE_P (TREE_TYPE (aggr))) /* Initializing a member of an anonymous union. */ - return build_anon_member_initialization (member, init, vec); + rust_sorry_at (Location (), "cannot handle value initialization yet"); + // return build_anon_member_initialization (member, init, vec); else /* We're initializing a vtable pointer in a base. Leave it as COMPONENT_REF so we remember the path to get to the vfield. */ @@ -3845,9 +3845,11 @@ build_data_member_initialization (tree t, vec **vec) /* Value-initialization can produce multiple initializers for the same field; use the last one. */ if (!vec_safe_is_empty (*vec) && (*vec)->last ().index == member) - (*vec)->last ().value = init; + rust_sorry_at (Location (), "cannot handle value initialization yet"); + // (*vec)->last ().value = init; else - CONSTRUCTOR_APPEND_ELT (*vec, member, init); + rust_sorry_at (Location (), "cannot handle value initialization yet"); + // CONSTRUCTOR_APPEND_ELT (*vec, member, init); return true; }