From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id C95833849ADA for ; Fri, 17 May 2024 08:32:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C95833849ADA Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C95833849ADA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::332 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715934767; cv=none; b=t0/1Y/Rv3KJeZJAjAVoRC5IJc+1sU6aa4obSWQNSTL1/guRju5p9zkATym7L2PNv4WpU76ucg/rtqxPSH2+DKEb2CaDGR2VO+CKkV2Olfcd/evdUbpHqnXjr3M9dSMsR2zE9ORxZ/lGz5O2vRi+5O9h8NNlmxCwsllAZRYTPTDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715934767; c=relaxed/simple; bh=fQRYW30jmddCzr3zNM7uVP5g6mewIRTZE79R3I/0gvc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XTtSlix02seoSVO2Q4a260pbC/yIBtwA5LoNn+k8xVdvBcKrDb/JcDkC8EYmdhASWYuhqVgS1fieKjCd34tNPKX/d52y2rBOdXbqrXe0s4LNdwFk61OhHe8hLt2Tpx200hCnMPu8IOnwEI8NhgzO5wC9HCFPInYYtn9BLF1DrEQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4200ee78f35so45749355e9.1 for ; Fri, 17 May 2024 01:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1715934749; x=1716539549; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/4Wf7zqJGVXFHtFGrqzXy5eOWqj8YE2+ysBEjKIi+3c=; b=LAtNSj7HEnzYoI7HUti2aZlqWV92FiphvL7GN0IcDmpI56G2dIHQi82S6W8ZBAOfyN Vj0hozRD8kZ2uLtDqqYrqxEcxMPaIgyCoS2WYle+dbbjIk80bZ/mQZ4QQNOYEtYzFh0z HJKc6pHC+gQCkwh3/1ZIRR7CmrvirQJWzGtFbaWCoJCKUl1UUHOKDlbWE9KdhzdeeOmb BkWIQASTJVW2S+R5/Y25X9gEUjy1zAmGf6XeVNwL3iFZbiKjfNZuzbOHmDhj0xAKoBlK BtFSCTphESPvh+dbZZMAMgT7gYoi0YMk1lq59lrP/7eo9X8y1KLDhjZWvAjl4GNXw08s iTYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715934749; x=1716539549; h=content-transfer-encoding:mime-version: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=/4Wf7zqJGVXFHtFGrqzXy5eOWqj8YE2+ysBEjKIi+3c=; b=ljHHcpJLhe0fGVOYv+HUyott8dR6b/yQ773mWOQTJC37R0NR6xbti5OjVu1HsiUCSI yyIpCZFR7xIyRODP+iAXw5kNnH+1HWvnlydpZ6bamwJSU3Mpg5IFIKQu0V6CAFcUa76H WQ/x+yd/IKBeAyGZmwFXbnoel/6MacDbw7Yrko8fDjHPaPMOXTG/jy4KF3rvnsQ4NOU9 IZyMuCfc/jhHyj/MHaz/ujIYFXj2L9t/ikdyRiPxSw3zuAtASCkqY6QkBnjGjzu0ctnf SEFc/iSk9N18lXbbGmm5NOk7OKv5twbjWH0EzEJbv+6Zai6mZ5H2SrRoomYwRWXZ59hq vPuQ== X-Gm-Message-State: AOJu0YxqHcaLJnZB/qhSXXdu28RD3kSjd8+5DV43EejO2B0hu1pfWweV kOUxtyTS/HMLNh+F59bsJmeOc4vJF3U4H00y0woaS4xn7sjcq3Vl4AhBZCWWj/szIoUDi0f+z7A = X-Google-Smtp-Source: AGHT+IF1stdmqpU4jSptrRg3sKJqhChbyWv/N+w6igYJmwlfBMrPT/OULY3HG+uFh5BEa2ydKB76PQ== X-Received: by 2002:a05:600c:1395:b0:41f:dec3:d5d3 with SMTP id 5b1f17b1804b1-42025fe9ab5mr72439875e9.19.1715934749055; Fri, 17 May 2024 01:32:29 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:de37:8b1c:1f33:2610]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-420273cff03sm75197045e9.26.2024.05.17.01.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 01:32:28 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Subject: [COMMITTED 12/35] ada: Fix crash caused by missing New_Copy_tree Date: Fri, 17 May 2024 10:31:44 +0200 Message-ID: <20240517083207.130391-12-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240517083207.130391-1-poulhies@adacore.com> References: <20240517083207.130391-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.2 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: Since a recent refactor ("Factor common processing in expansion of aggregates") where Initialize_Array_Component and Initialize_Record_Component are merged, the behavior has slightly changed. In the case of the expansion of an aggregate initialization where the number of 'others' components is <= 3, the initialization expression is not duplicated anymore, causing some incorrect multiple definition when said expression is later transformed with Expressions_With_Action that declares an object. The simple fix is to add the now missing New_Copy_Tree where the assignments are created. gcc/ada/ * exp_aggr.adb (Build_Array_Aggr_Code) : Copy the initialization expression when unrolling the loop. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index cff04fc1b79..9c5944a917d 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -1649,11 +1649,14 @@ package body Exp_Aggr is and then Local_Expr_Value (H) - Local_Expr_Value (L) <= 2 and then not Is_Iterated_Component then - Append_List_To (S, Gen_Assign (New_Copy_Tree (L), Expr)); - Append_List_To (S, Gen_Assign (Add (1, To => L), Expr)); + Append_List_To + (S, Gen_Assign (New_Copy_Tree (L), New_Copy_Tree (Expr))); + Append_List_To + (S, Gen_Assign (Add (1, To => L), New_Copy_Tree (Expr))); if Local_Expr_Value (H) - Local_Expr_Value (L) = 2 then - Append_List_To (S, Gen_Assign (Add (2, To => L), Expr)); + Append_List_To + (S, Gen_Assign (Add (2, To => L), New_Copy_Tree (Expr))); end if; return S; -- 2.43.2