From patchwork Tue Jul 18 13:13:42 2023 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: 122026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1740713vqt; Tue, 18 Jul 2023 06:20:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlHPtVqiq1lLJYzexLfj6SRGnFFOSLnbVN1N108ZKbyOFsf9EaR/Poda+3oMADU+T69KHNtA X-Received: by 2002:aa7:d9d6:0:b0:51d:9dae:a591 with SMTP id v22-20020aa7d9d6000000b0051d9daea591mr13699390eds.21.1689686432746; Tue, 18 Jul 2023 06:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689686432; cv=none; d=google.com; s=arc-20160816; b=C7m9Amgj+FQd1/vp2GWmVWRTV1sXTqccgvoVL5y8cupgycvgfE/HF/05A/DqvkfA5D zNNtyBCbKWb7ckZfwnOy0nUL2UOpQJPjNH/4y62MwSzNlquCNs6MZC6rFXk5edUjRWj9 8/DMQpE0jFt6ziDzHsTmV33aIzzHw0Fjf/7tRFFv3lS/o5OT40bN5FdOI3k16mXDSjMz jCRL5r9iuLwNJGkXaytd+AwvvcXc6NfGL8JhwN7jqZ7PgmoncUXZvYI5DQpFJ2zKE1iB l76xGxTQCgj9/By7Nt4OZ/nh5gsAn6ToXE8WGyeOC+azE/STk9MHsiGn7vMV0Ia/vEJy sUxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=spdKvDJzlaTLX6bhG48cSOI6Lgef+m81KX+Myu35kLs=; fh=qgQjCcgTOS4PqJmTmRtvqfvUI8DwWNjxI7TYi3qv/40=; b=BlA897YVgwBuM/LobalSOay0yzbp0YRyGyAi9x7Q8PlE4n18jDFFRPCf5+ptKrCPqZ D+y9gzeMFryZT8a2E4BF25j9ArSY5bQf3WUriWzygnwVf0z9wF0pZJ5PXo+K7lPhAz4o KZXMSaN9zEFhdAHz3PNQMFzbO+3K5iVkoIyWCM1GrHvZyugQUHuXI/TPM9DTZYzSkaFe NrTm7tPdkyM6lR4nyyox1+5A3tAHfno/o7t7BPsEmDiBc9heFkRNf0n18JeUQPeocqoe mYkpBL57I10r9s3CXothaeyYLRfHXZDW60gnwENpucfVswDNwX6w8MenNX+vIJ01JalD VhXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RVSahBPW; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l3-20020aa7c303000000b0051e52bd68f2si1281113edq.192.2023.07.18.06.20.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 06:20:32 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RVSahBPW; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0A46387101B for ; Tue, 18 Jul 2023 13:16:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0A46387101B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689686175; bh=spdKvDJzlaTLX6bhG48cSOI6Lgef+m81KX+Myu35kLs=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=RVSahBPWC2hNyQ6daoajqBYcUo2K4eRwHKwaOKyIVv1mlV71qar6AsFsPWcubTW/5 Wh9VXPap5niGlsu8ytF1I71GF+h/VHepRYxZK2TDSCe3HOJCkLSxhrvfrGPe9nJNhC dUlDkWsppmidVXoVJ0PSZT0a326Fhce73nVpc9vg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id B82B0385C6E4 for ; Tue, 18 Jul 2023 13:13:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B82B0385C6E4 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4fbc0314a7bso9264333e87.2 for ; Tue, 18 Jul 2023 06:13:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689686023; x=1690290823; 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=spdKvDJzlaTLX6bhG48cSOI6Lgef+m81KX+Myu35kLs=; b=OoBsaah8DMBVqZcpVFMbOUiQU5Qfy+WSrEu8Vfc3Prc8Gr0WGAUBWAZWWOWPorDP2m mN7LGK75IcfWh0HSs474l62fA121gbRcj/qABofGyN3+kOipsDYfL1VUaMPNWMMbP4j6 k1kLbyR6L1SBEAX96GsIu14oQHHLsD0uM+K9EC36QIHxmjPATfAh+tUJD4sjoATO9TYU GecDX9wPucq9h03EFQEE3yemZUazN0nKVIwacTcTRdAdSpoeUJVvHFbVervpeVhuFqn9 RgeBEsi7gEAvxFGkouPD32rBWd919YzNY1SXByaNbPkgb0Xs881cAthlckEGVmhyqr5/ a+8w== X-Gm-Message-State: ABy/qLaXAj+J+X9H0VC4WeVlzeOxLJ3eMB5NRNKhtQQgdllLsExUNsF5 eiF1hX/NR5HpWsPE9sB1nYQVkMXeBWUwgQmOmLfUZQ== X-Received: by 2002:a19:2d17:0:b0:4fb:8948:2b2b with SMTP id k23-20020a192d17000000b004fb89482b2bmr8673363lfj.48.1689686023229; Tue, 18 Jul 2023 06:13:43 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id f22-20020a7bc8d6000000b003fbb5142c4bsm10452405wml.18.2023.07.18.06.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 06:13:42 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED] ada: Avoid iterator conflicts in container aggregates Date: Tue, 18 Jul 2023 15:13:42 +0200 Message-Id: <20230718131342.81513-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 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, 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 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: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771764640452580671 X-GMAIL-MSGID: 1771764640452580671 From: Viljar Indus Create temporary scope for the iterators defined in a container aggregate so that it would not be put to the same scope where the expression was used. This would otherwise lead to multiple aggregates with iterators that have the same name leading to a name conflict. gcc/ada/ * sem_aggr.adb (Resolve_Iterated_Association): Add temporary scope when analyzing the Iterator Specification. Use preanalysis instead of Analysis to avoid polluting the tree. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index ecd508a66f8..364217d03db 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -3231,11 +3231,24 @@ package body Sem_Aggr is Typ := Key_Type; elsif Present (Iterator_Specification (Comp)) then + -- Create a temporary scope to avoid some modifications from + -- escaping the Analyze call below. The original Tree will be + -- reanalyzed later. + + Ent := New_Internal_Entity + (E_Loop, Current_Scope, Sloc (Comp), 'L'); + Set_Etype (Ent, Standard_Void_Type); + Set_Parent (Ent, Parent (Comp)); + Push_Scope (Ent); + Copy := Copy_Separate_Tree (Iterator_Specification (Comp)); Id_Name := Chars (Defining_Identifier (Iterator_Specification (Comp))); - Analyze (Copy); + Preanalyze (Copy); + + End_Scope; + Typ := Etype (Defining_Identifier (Copy)); else