From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id DA6053858022 for ; Tue, 13 Jun 2023 07:38:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA6053858022 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f8cc042e2bso1525245e9.2 for ; Tue, 13 Jun 2023 00:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1686641906; x=1689233906; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QDWJ8/UCoAirXGIvL7/22NxylL78fu9pkjOptejCqcU=; b=WCQUkZVeV5LI2iyGMpgyQATuwoUUliaRESaAhqRFNKyvzQ79398ApKHooc3/iTf/zG jltHgtku/JbuFaLeDFBZqmN3jBmoWsj+cxWjfoIG50f8e+XHMjwdIXoQnvzA3QDvHphs yRSUVTF6eASqxNwd+pin8Jd7HIn/ucHBbg6NuEa6w8m31e1H45BksGcQbvMjjlWJTJpZ Tl1kEChaHi1190eD1IZouJmKMK6FNtJ/R8agXwF3Fsw5h+vE7BNLzMmw53HOI2BBP6tB 17VUXdnRQKf4NJxn9azzJN7gPPYM6Qfqnwy+OM8fq7UbaeJf2I0V95kVp2xfhmbL3yJf kMhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686641906; x=1689233906; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QDWJ8/UCoAirXGIvL7/22NxylL78fu9pkjOptejCqcU=; b=Eh6DW6x1ftL54WHBEU2WoGWhwuoN5Q3+2Elx/UWdq/wO3AZc4RvbygztVgidj1Aarn PWt+FuKRaaZIHKTZhsG5+nrzTQkRaRzLdGQSXtd7NfNXil9CaLOY3uQdvy07Q6lJDWAP isuGtT8cEsuYXK2vtHnaNKoXUGp3UgE+vEYvEUNUoNlzyw1EBmnSRvWbvFvt5MmkQOYf hg8jnfdCVTKvhpUYDwaNSN4kvqyJ1wS1+1aS6TDUNRogd+j0nj12ATbWTfCEDtT3YVz/ MtCuPxRJbcr+ZtZYOnSWqvYD/h9XBC0JXvw76FHslzJS2410oPTZRn0sTmVGpr+0d6QI 8dPA== X-Gm-Message-State: AC+VfDyW9NwWgQe/E5/RkTF2MA0xDFEUMDMdYS+RT3oy4R3cqD4suAHh o/ebZT15tg/zOm0EcMLJpgYv01x4w7+po7PZqsn2rA== X-Google-Smtp-Source: ACHHUZ7Nz6jw+uzm2avRwexhresomNFQjkLj/hDzGXQTjwFcZuJFXt5NAhLhbXe/HlJRxDFuhcq3IA== X-Received: by 2002:a5d:6245:0:b0:30e:3d5a:b2be with SMTP id m5-20020a5d6245000000b0030e3d5ab2bemr4732012wrv.44.1686641906750; Tue, 13 Jun 2023 00:38:26 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:bfa8:5d29:40e5:cc66]) by smtp.gmail.com with ESMTPSA id i1-20020adffc01000000b0030aee3da084sm14496150wrr.49.2023.06.13.00.38.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 00:38:26 -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] ada: Fix iterated component initialization Date: Tue, 13 Jun 2023 09:38:25 +0200 Message-Id: <20230613073825.240197-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.6 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,T_SCC_BODY_TEXT_LINE 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: The call to Resolve_Aggr_Expr may leave references to temporary entities used to check for the construct legality and meant to be removed. Using Preanalyze_And_Resolve correctly guarantees that there is no visible occurrence of such entities. gcc/ada/ * sem_aggr.adb (Resolve_Iterated_Component_Association): Call Preanalyze_And_Resolve instead of Resolve_Aggr_Expr except for aggregate. Co-authored-by: Ed Schonberg Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 3b2d0347b41..843606ab4a1 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -1862,9 +1862,14 @@ package body Sem_Aggr is Expr := Expression (N); - Expander_Mode_Save_And_Set (False); - Dummy := Resolve_Aggr_Expr (Expr, Single_Elmt => False); - Expander_Mode_Restore; + if Nkind (Expr) = N_Aggregate then + -- If the expression is an aggregate, this is a multidimensional + -- aggregate where the component type must be propagated downward. + + Dummy := Resolve_Aggr_Expr (Expr, Single_Elmt => False); + else + Preanalyze_And_Resolve (Expr, Component_Typ); + end if; if Operating_Mode /= Check_Semantics then Remove_References (Expr); -- 2.40.0