From patchwork Tue Nov 8 08:41:55 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: 16936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2569995wru; Tue, 8 Nov 2022 00:45:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM6+PYkY10jdLuZZNQo3AcUWH1Bj4hBJFmHvoIW8QRo2hWN6bnBBa4ddEeswFICD7rtGbTGB X-Received: by 2002:a05:6402:544:b0:463:beae:427f with SMTP id i4-20020a056402054400b00463beae427fmr38157354edx.29.1667897132206; Tue, 08 Nov 2022 00:45:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667897132; cv=none; d=google.com; s=arc-20160816; b=njFjHLeu5zpmQoRTx3UDkVZWQU0akNzm4uKt8vgJHLJvGZkcBA+S5Kex73dGrL09zD nNxt2PWEdud6O3pTGRD6XdasdyyaWgM9hbT7UxSnIX9u4h581X7C3S6EtgyXglsitRLY zwWZWqkz4hhEwWjc/z97GfZoD1dA0s+UyKLHAYUEVWWC7miidtTvX+x7HmuXUOb1OgtE +xKpwTf1E9WwnK0HGCTunD0w/5MB2dXmDeL8VlakpavQathfegELgnaRI+BdQsRz36er Z5eBGlWMfCBUFu5ok/1FuTtHyvkbuabgaZPR6wUe3NYIwe0UTIhNBalmhRpV/8oS1sjX 4BhA== 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=wocxRLvnA3BxunY5i4gje95ZCsQbuVdakMqKye+3v/4=; b=TjSg/RiD/PbEaBwa9H4f7WHz+xMUtOpxozCyfRTThbMvX5TZYd17zi6c7mRKwjzoTZ ISgSRn5HQ7uAmBrbMKT45tUoqlEKISu47mR8IPcqg0s9v8827GoGv7me1TD7rnapSqMb aMut9FJaQav9Z4ng2dxJtKKpzmMIIbHv4M9uPXsGa+8fdEU0VAQMQY0SeRVHv+mL5Gz+ X+p4/u1wROkQHe8ESWDLgeSolZ82/LgD3kpsTour8a+3NU1MmnZvWI3yisRRL6EU5Ys3 4Agfv5pnEeXKjAuW54u6j/lUf2HuYvGNNOgDxpni7CIGzbPp85y54gJT9WFZos2FdQes ENLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TmfLkyfR; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ht14-20020a170907608e00b007ae4717bf08si12513022ejc.359.2022.11.08.00.45.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 00:45:32 -0800 (PST) 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=TmfLkyfR; 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 6FE0A3857BA8 for ; Tue, 8 Nov 2022 08:44:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FE0A3857BA8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667897049; bh=wocxRLvnA3BxunY5i4gje95ZCsQbuVdakMqKye+3v/4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=TmfLkyfRVSKyCPSZZo4dHHVYVetdB4u0Cyj2YqPjM3vYAgZXxf1VKl6VynZUKb/76 3IYQNcLmWUHVbE0YCrfTgi1+ECyLZaMS9bSUApc3AIIlRmDiBNEms0BhU6Ul06h0DA imDVQn+hZMrqZIOut035OucQJcnM/uHtw6+RATjw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 8F20A385803A for ; Tue, 8 Nov 2022 08:42:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F20A385803A Received: by mail-wr1-x430.google.com with SMTP id y16so19729434wrt.12 for ; Tue, 08 Nov 2022 00:42:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=wocxRLvnA3BxunY5i4gje95ZCsQbuVdakMqKye+3v/4=; b=eCzntX4rbgxZcpw105k07jxHs6Xq/nHKsmUv0cyBrZMEEgSYjGWUf3EmtKS2nE14Q/ 24prj3RH0zeTUe9l1yfWQ3fFVvG1E/23U9Z2Hgh9ty6w8IU5jtIoZSC/lk80d/8lcJex 1TZ7cNntK6qo61lS3rqmtrw3dq2lQG9L5GbqnMj7fL7alsvRRHJOif46ID9EhDsBXVYl IEnJHBd9pA+qNnoJy9NsZrB9aZONyI5eXWMm2EA8TjeMqrHgV+TopwNnsM9SSrfyF6qu pR0mE7tmgxeQtqUo0qnelKzsijo8TjSFfbBuu5HWpVqbLYoYXI7c+/HKEbC0DRoTp4GZ oXPQ== X-Gm-Message-State: ACrzQf2HBKy2lg+e3/Y1wtZ4SdzTLwobcWx99OYuLJArX/p7ovBFZBp3 8uJCSiHpQCxviBoL7+MJOkJFXQoKFArq0A== X-Received: by 2002:adf:f8c3:0:b0:236:9c97:6f6b with SMTP id f3-20020adff8c3000000b002369c976f6bmr33367821wrq.548.1667896919446; Tue, 08 Nov 2022 00:41:59 -0800 (PST) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id z17-20020adfec91000000b002366e8eee11sm9405687wrn.101.2022.11.08.00.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 00:41:59 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Reject limited objects in array and record delta aggregates Date: Tue, 8 Nov 2022 09:41:55 +0100 Message-Id: <20221108084155.300994-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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.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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748916903642319342?= X-GMAIL-MSGID: =?utf-8?q?1748916903642319342?= From: Piotr Trojanek For array delta aggregates the base expression cannot be limited; for record delta aggregates the base expression can only be limited if it is a newly constructed object. gcc/ada/ * sem_aggr.adb (Resolve_Delta_Aggregate): Implement rules related to limited objects appearing as the base expression. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 383f18f7301..4da05dd7317 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -3421,6 +3421,18 @@ package body Sem_Aggr is Analyze_And_Resolve (Base, Typ); if Is_Array_Type (Typ) then + -- For an array_delta_aggregate, the base_expression and each + -- expression in every array_component_association shall be of a + -- nonlimited type; RM 4.3.4(13/5). However, to prevent repeated + -- errors we only check the base expression and not array component + -- associations. + + if Is_Limited_Type (Etype (Base)) then + Error_Msg_N + ("array delta aggregate shall be of a nonlimited type", Base); + Explain_Limited_Type (Etype (Base), Base); + end if; + Resolve_Delta_Array_Aggregate (N, Typ); else @@ -3432,6 +3444,11 @@ package body Sem_Aggr is ("delta aggregates for record types must use (), not '[']", N); end if; + -- The base_expression of a record_delta_aggregate can be of a + -- limited type only if it is newly constructed; RM 7.5(2.1/5). + + Check_Expr_OK_In_Limited_Aggregate (Base); + Resolve_Delta_Record_Aggregate (N, Typ); end if;