From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 6CDA2385783F for ; Tue, 21 Feb 2023 12:04:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6CDA2385783F 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-x430.google.com with SMTP id t15so4268543wrz.7 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=GR68KRMGNFRrkXJSjQSs8Y1GCNSdFNjr9tmECrvmrgZR6TyvJPkNbruBKjvp8Y75Y6 EzkBetuHa9wRrQ11jgEt8sH+VteeZeKmmR2AJzOGsFOATU+Bk0WKyV4vVFbgeqJ8KR8N aK/bNqmreR29xkuTxoXd4yDmNaxsU+IjiJPRqEDrn/j4KymgdurTpXpiT5zBbzO/zd09 HWUap2nbnGuXXVCV5paEejCo7DO4gUfP06dBELOKmTIDn2eZmqOKXfxgqCvK9q32i+GR j5DTpsT6tGl9oI2/xBYhpxw2ZlfYJgELOkmH39oHbmD87WbnI8cj3SLYPw/720TDz9Vx DYMQ== X-Gm-Message-State: AO0yUKXzixcLiSaEA1+X7B8btX3wFVHvB8UG/jbeYDNP5RfBpTszSgGV PIHs7Fyogc/UUHp8WNyMLWH7Bs2jOOC3QihEuA== X-Google-Smtp-Source: AK7set/Dx6xpC/NUJ6livP9del3XAPKeYmdErf7besI3D7UN4T3chrOu6rb+9kRtRC+dFtTj1V/4rg== 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> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.8 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 List-Id: 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; } -- 2.39.1