From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-wr1-x430.google.com with SMTP id y16so19729434wrt.12 for ; Tue, 08 Nov 2022 00:42:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wocxRLvnA3BxunY5i4gje95ZCsQbuVdakMqKye+3v/4=; b=fVbtezHY1bXFKhzRfoLw/Vs7APRFL7UYY+XtiotWvinkrF+JqpPMZMJKkaiaC3Dp2m Qce9wmx6fM3dAR7VN3krksVtzlPRi9eahecl4VvKQJ2ewJmreHElihKv/8n5RC/h13zP turNw9/FfYLARtcDD0gkt0ekl9ZdaXADcP9yMujmDKyAvZRq8v8daPMOLn/b4CO1+h6L kTgo7aG6/+67BMfZOsVErGpvzeTLbxXg2HR6pU9YeW1iEhmdi0hvfYmtP/e0dL/jawqD iFqCMmSpvPhAxJBoA9Z4iST4gCUAr68DAHIujrwRzOP+0/NFE5o1XNrMxSc9knfI/d40 Tzow== 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-Google-Smtp-Source: AMsMyM426et7h7bmFTrClxQ4iWE37W+k6f7SqZyQSvIRa/pORoHalow2HD2eB0CY89Vjc3uNJFOFIA== 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) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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; -- 2.34.1