From patchwork Fri Aug 2 07:11:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1968209 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=CoIWoPVd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WZxyk0T4sz1yYq for ; Fri, 2 Aug 2024 17:18:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A8475385E45A for ; Fri, 2 Aug 2024 07:18:51 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id C94DE385DDC0 for ; Fri, 2 Aug 2024 07:12:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C94DE385DDC0 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 C94DE385DDC0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722582768; cv=none; b=rZeFTkSgyfkUXZWujyoxzigsM4Pr+bAL3ovxcVY4nmxIt3hD1X5pJpk9PLSlYbde/WKkNL4UfT3QDOITFbBSLnPic3Rwt9sqjZcgKkDTRfCSTAvkFr6Ok8MMj/LjJ4pacDwQjqgxXVbI51s4Gl+jBv9jIrVnB17H65uPU7EuAhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722582768; c=relaxed/simple; bh=mD5HSSee7KGjZCLOFBRxARR6UowQB0fowCFs4UjG/HU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Uggy6Hut8LpNwRCxlJayqB1uVq3Eeox2fMPZz9SWXL3lc15lYJ0LYWPNTEJ4EHHUnqM5c1LU3xgI+Pi0iWTx49gKEZcDATuX2RpJJgz0UB7tFqNy1Bo2y2uYXQZ3sC+AdsmmT1VpCXFdakogBLeipZrn2v8G2oVg2YM8q//vK+0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-36887ca3da2so3614241f8f.2 for ; Fri, 02 Aug 2024 00:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722582763; x=1723187563; 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=64prF6zwfSXaSeEUmwR8e/fmDtEbPw/TpaVYfeWBCOs=; b=CoIWoPVd1dp79uC5wpCVhiKtow13Fz/o0hJqgnVvm0dywgN7hupctcbh2HECYljfRt yRQWp2ZYMVHgagbj+y11vrgSxTJ9iaEVjcrAZpifJXCPl6q7M2lRFuknJC/nYb9DoazE prTPTpXdTBSv0NHRBifY0u6whb02lkomzQkBbjfiD+hzssE4dwm4l2q0ai04RQDAoES1 Q23RKppHiUtrAzF56k3RDSUuwjGllSy1xwQdQs+v6g82BvJ16zFYvRpvXFkMlRlkEsj4 PZGlfV2hBUBebtsSpkuT92MaZOlxzkxbJEMYMggJnxzTx7+dPDo/Zd6UHsEVbKqJ9D/c utoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722582763; x=1723187563; 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=64prF6zwfSXaSeEUmwR8e/fmDtEbPw/TpaVYfeWBCOs=; b=WUImhg8dIsm7p2G+MdSTRpyObpCgMVjKg13yMQ/byirzj2DpOnM0Qb/ddyiz4i6lz5 ejmTm9QR6FYBHmIeHKmFQqOcS4mR8R48FWcLzS6+Mtox2aqyIbl5fzmXqTOuinxaspXs UmSxELVTBfmHYQWH3HizVSJanmBcs9RCIw4k1Ar+gzuIWmdCczwufIoSF9AiaC7HNUiS /114n5zAM2RWfTYMTDn+xw227P0oBscLEYmU/ilvJYqJ8xBOIQ89Faj5riKXwRifV/mB q0LUiM78x1bBU7kCm9LM9HeCB/JJBdknze2oyVkzh+DHD3CR+gKKgK0vc0rY6dzg+i/t FbVg== X-Gm-Message-State: AOJu0YwGcjPnC8js5YuaVmVvd3te2ZAtKSXTYQyo5Ba/tLENF6CshER5 LW+ZZEJyim/gXg1ckF4gL9ReLyzajBNtIZBtpB9wLsH6chG6flsom8wug4Fxb4a+XtpiYsWEZPo XaA== X-Google-Smtp-Source: AGHT+IG0dR3u7gf9fwg9pVTeenUGjNG/pZNq1zwcjo2iqiuqONtxiWq7lQkUhFvD8sVBQP+Q6qtJHg== X-Received: by 2002:a5d:49cb:0:b0:368:7e10:6995 with SMTP id ffacd0b85a97d-36bbc107e20mr1225025f8f.17.1722582763472; Fri, 02 Aug 2024 00:12:43 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36bbd059932sm1195770f8f.69.2024.08.02.00.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 00:12:43 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 25/26] ada: Fix handling of iterated component associations with sub-aggregates Date: Fri, 2 Aug 2024 09:11:42 +0200 Message-ID: <20240802071210.413366-25-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802071210.413366-1-poulhies@adacore.com> References: <20240802071210.413366-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Piotr Trojanek Fix a number of problems in handling of actions generated for a 2-dimensional array aggregate where the outer aggregate has iterated component association and the inner aggregate involves run-time checks. gcc/ada/ * exp_aggr.adb (Add_Loop_Actions): Actions are now attached to iterated component association just like they are attached to ordinary component association. (Build_Array_Aggr_Code): If resolution of the array aggregate generated some actions, e.g. for run-time checks, then we must keep them; same for the Other_Clause. * sem_aggr.adb (Resolve_Iterated_Component_Association): Unset references to iterator variable in loop actions (which might come from run-time check), just these references are unset in the expression itself. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 14 +++++++++++--- gcc/ada/sem_aggr.adb | 9 +++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 8496fcd9b00..aa6079d82b5 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -1259,7 +1259,8 @@ package body Exp_Aggr is if No (Expr) then return Lis; - elsif Nkind (Parent (Expr)) = N_Component_Association + elsif Nkind (Parent (Expr)) in N_Component_Association + | N_Iterated_Component_Association and then Present (Loop_Actions (Parent (Expr))) then Res := Loop_Actions (Parent (Expr)); @@ -1962,7 +1963,9 @@ package body Exp_Aggr is Bounds := Get_Index_Bounds (Choice); - if Low /= High then + if Low /= High + and then No (Loop_Actions (Assoc)) + then Set_Loop_Actions (Assoc, New_List); end if; @@ -2038,7 +2041,12 @@ package body Exp_Aggr is if First or else not Empty_Range (Low, High) then First := False; - Set_Loop_Actions (Others_Assoc, New_List); + if Present (Loop_Actions (Others_Assoc)) then + pragma Assert + (Is_Empty_List (Loop_Actions (Others_Assoc))); + else + Set_Loop_Actions (Others_Assoc, New_List); + end if; Expr := Get_Assoc_Expr (Others_Assoc); Append_List (Gen_Loop (Low, High, Expr), To => New_Code); end if; diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 656d789de73..087e324b5c1 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -2212,6 +2212,15 @@ package body Sem_Aggr is if Operating_Mode /= Check_Semantics then Remove_References (Expr); + declare + Loop_Action : Node_Id; + begin + Loop_Action := First (Loop_Actions (N)); + while Present (Loop_Action) loop + Remove_References (Loop_Action); + Next (Loop_Action); + end loop; + end; end if; -- An iterated_component_association may appear in a nested