From patchwork Mon Sep 5 07:26:05 2022 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: 970 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp57592wrt; Mon, 5 Sep 2022 00:32:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR607K45Oh9uJf8UE+n/DO4aFgd/uuBJ4uhRw6fS1/D2sRQ0kSY4umG00huAbzr/q8IRcjfQ X-Received: by 2002:a17:906:5a5a:b0:741:559f:f539 with SMTP id my26-20020a1709065a5a00b00741559ff539mr27728379ejc.3.1662363127501; Mon, 05 Sep 2022 00:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662363127; cv=none; d=google.com; s=arc-20160816; b=MltA/11AAnslVSJvH2XBovHhpPSVy3kYZX7A1+cuJIDHC3HpbX5O/QMuMkR3jN0nnf a3tNTvaq/nkYW35+/HLbdTb+XFsdB/LM88OMrSnjvSaNvsbwLdf9NmLyRW3JD709vTsG x9MCMI69mBBrJOavxo9m3LFasVro24ieQzJBi7xbi0cLv9b+M3JFT9c6KoZyzp27NFfu 9CTH+rWcQz4C84elm3ntak8c4bao7sxiJAx1DP1cOXsmBSLy+tTjo3vf8o8q89eWEdZq PrtdhQTGfiAkqu5VTKfMvgfUJJd0Rt7ZKJJC2E7Y5FyF3/p7iEgFqP9LG0npiJOVsAmD 5vsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=QO//7wICD5nYDCxpGz0i5cIguJjmxxAkYPRa/fvQlr4=; b=mrruRdU8FlWNz+kKE/t+L5+TL401dvQpY4SQ/M7xRFS7O2PuvdZw660dwr17byr/a4 m7ALLX6IPyZlondbDFGbRvTMm1wJsQvF3oYR+0GVhC3mqXTG1e+COFAUdEW+caxQf06G Ab3ZdHh5hybLPChP68yWnQ9rWv8LIVw/OnMAxZP9FNqtx7hLgBDowUUxTw3ml4hKmS6m mFnO3uhXyHRVRSQ6W1YiLyr8zJO/+PLL/soGJobWKl82VV0qeSQDZv7DGEHElQuKnOIN Xa+izqEJysb197OsK6zYSAw0s9rlWgOlot+Lw0n4d1uDMN0H55FlJmmXyA3EmwXGhCVo /l4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PCcPGaR0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id x44-20020a50baaf000000b004405af7da47si6726168ede.564.2022.09.05.00.32.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:32:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PCcPGaR0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 BA8023851AAE for ; Mon, 5 Sep 2022 07:28:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA8023851AAE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662362932; bh=QO//7wICD5nYDCxpGz0i5cIguJjmxxAkYPRa/fvQlr4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=PCcPGaR09mZZt4Tulf+mZf/jrLEG2WujfBU5Q0CAsVBHxx67U7pOVnkkzqmmVa8TD FieL6W0KYGYZxXPeoPwG7EBxkXvevJtIsucbCJdx6+X3azWEvWHZeDJApbRd4Tdd+t 0Y6Pfan1vgC7Q/Kpjrr+PeGZxfSsDhYZKY6KQNzI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 65E59385697A for ; Mon, 5 Sep 2022 07:26:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 65E59385697A Received: by mail-wr1-x435.google.com with SMTP id e20so10045739wri.13 for ; Mon, 05 Sep 2022 00:26:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=QO//7wICD5nYDCxpGz0i5cIguJjmxxAkYPRa/fvQlr4=; b=UNeLVs04ybQtdDyZ4ightSKJm+QmCJ4hw7feOZzoNc2hMXynMb7SJwRYrzwhSK5bDX LohWO2OvRTPzYIrV7ItbPRVhqcCAuENul9wHBNzNjqiOGBTdwVGAa80HcQ2VWGVtLRUC GzXTpmm6fSCP5mT+m39qcXQFH3GPI0tR74RWZMVXosKct4RHqXvx0GbVI5e8z2x4nPkw D5jwdhQf3j0FotC4Jp/rey7tSC2uRU1jWg+XZ+zq0dChhBrUy+0gMMy83N9XEw+5yYnR cm/mOylWso/wnEUqAJEUe+4sao/wo9qAbIS+X33hwWycSt40cCupm2I1+BJERxwU9Vy1 Onig== X-Gm-Message-State: ACgBeo3xHrmlQIqtp0UDDbTsIuEek2vpqYduobBrLcHBPvuFHm4sNqIL k/Gs+CW07MoPOJBc88s16MWNc0d/M6XX+w== X-Received: by 2002:a5d:64c9:0:b0:226:dfa0:3fa7 with SMTP id f9-20020a5d64c9000000b00226dfa03fa7mr18567387wri.350.1662362767055; Mon, 05 Sep 2022 00:26:07 -0700 (PDT) Received: from poulhies-Precision-5550 (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id z10-20020adfdf8a000000b002255eebf785sm7984893wrl.89.2022.09.05.00.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:26:06 -0700 (PDT) Date: Mon, 5 Sep 2022 09:26:05 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Detect expansion of iterated component associations into loops Message-ID: <20220905072605.GA1174715@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.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 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: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743114078905802472?= X-GMAIL-MSGID: =?utf-8?q?1743114078905802472?= Iterated component associations are expanded into loops, which GNAT should detect as violating restriction No_Implicit_Loops; same for iterated element associations and delta array aggregates. Part of cleanups for correct handling of iterated component associations in SPARK. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Two_Pass_Aggregate_Expansion): Expand into implicit rather than ordinary loops, to detect violations of restriction No_Implicit_Loops. (Generate_Loop): Likewise for delta array aggregates. diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -6430,7 +6430,7 @@ package body Exp_Aggr is Left_Opnd => New_Occurrence_Of (Size_Id, Loc), Right_Opnd => Make_Integer_Literal (Loc, 1))); - One_Loop := Make_Loop_Statement (Loc, + One_Loop := Make_Implicit_Loop_Statement (N, Iteration_Scheme => Make_Iteration_Scheme (Loc, Iterator_Specification => New_Copy_Tree (Iter)), @@ -6562,7 +6562,7 @@ package body Exp_Aggr is Attribute_Name => Name_Last)), Then_Statements => New_List (Incr)); - One_Loop := Make_Loop_Statement (Loc, + One_Loop := Make_Implicit_Loop_Statement (N, Iteration_Scheme => Make_Iteration_Scheme (Loc, Iterator_Specification => Copy_Separate_Tree (Iter)), @@ -8000,7 +8000,7 @@ package body Exp_Aggr is end if; return - Make_Loop_Statement (Loc, + Make_Implicit_Loop_Statement (C, Iteration_Scheme => Make_Iteration_Scheme (Sl, Loop_Parameter_Specification =>