From patchwork Thu May 25 08:05:54 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: 98868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp202318vqr; Thu, 25 May 2023 01:25:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5hCLVkbyCzbn/sck5jD3GcaG9QN9Iy803Flm01TDaNcE3ptDmArtUaq1mmFx2iKXodjaJD X-Received: by 2002:a05:6402:1387:b0:510:e902:9690 with SMTP id b7-20020a056402138700b00510e9029690mr3659496edv.33.1685003116995; Thu, 25 May 2023 01:25:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685003116; cv=none; d=google.com; s=arc-20160816; b=U4aqU9BmUGKz9tr2ahrfp82BtgTTT4FSmXmaP5fBUZJCP89TiKuaSfnqt4RhOyXryB 7lXqPmvDU0NjC/IjxT2qJgaMohR45DjMFyE0sUbDDKGyM2cqKRaUct8B1Qhtf/Wh+yiD FI1tZ9dT8KzMwz1Ph8uGnFfa1xeVUn6EVrsVKyeOEgW/HyyF+ub4/2NCnOqrEs7+/GH+ 4oxv9u/6AEuaUeUhiUHtD9bvWggC1GCj06iIC7UAXj+Kc5bIE3BS3rFpn6rwVA22GGZv fPcCFqyxP5J4oBGyOuN3k17tzhO8k0hCgoMFanPgTa1aQjdNk+tF54PMXzf4tNc1ucHp LgTg== 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=LyZqiVx1x1KiehDLGZjWby2X50kTwCqhS6Key9hL99w=; b=fgLTB3gn+tNadUK49QaHX3yo5HfNuXi1wKD8L6Qo8IhOUcIowMdHoU8jupDPIpYNt3 9Znsh+U94UsNMHgBCsCMlTxjlZ4U/ny34mf/9NUBVb1/nZKe22YDQivaO6V4g45nfYvs KKBEbmWimPKa8eTx6CWQlJ7dWhN5If5XXlzEQesn8MLGse+vfj10gxVwpHRK/dbZ6Kck gcnrsuFZijCQrdRzX47mEbKE8xqFG3tkaSKz/F7tNnlnSXpe4zeIo2PVAL3Z+xF8aRjh wgw/57/UPhogxXpNJAZCdrP9ja5hq+9gbmaUjIiHy7uSgR7lLX6/3LNfrcp0NJdXHlJ3 z40A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hYg8iauP; 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c24-20020aa7d618000000b0050bc4795612si600229edr.249.2023.05.25.01.25.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:25:16 -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=hYg8iauP; 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 555943948A4C for ; Thu, 25 May 2023 08:16:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 555943948A4C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685002584; bh=LyZqiVx1x1KiehDLGZjWby2X50kTwCqhS6Key9hL99w=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=hYg8iauP3sp1GPH5A3r1MG58++Bb5PrCqsK0B8Y5YwBiGzKdKyHC4/Pf+QZwRvFUY k8kJx1afFhd30xSxRn/rWur9iOfWDRTw8DBYM3lIA+o20khhMyORAiP1wDEc0uH/Uw v3DKNHqQUijp/wPZqEGpvdtyJfLEyhu3cMUXST48= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id C93933856DDC for ; Thu, 25 May 2023 08:05:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C93933856DDC Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f6a6b9c079so1939425e9.1 for ; Thu, 25 May 2023 01:05:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685001955; x=1687593955; 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=LyZqiVx1x1KiehDLGZjWby2X50kTwCqhS6Key9hL99w=; b=bxVjEutjtFhcsjozU5KH3zK4S6j1GJVqDrjEua1cw58UmoX8YakviEeJXe4QoPTBF9 db+yTC5VkTyTEb+sTr+OnIl0Edg4asmmLrpp0osF2HDaR3DCFsmcrzOxa5WwsRU4HCR8 ayO/FwLDuLQ6COY+laKJhclEgrkwFHdBef47etI0UjLrUKJytMu23Y2rXl4wV1ReER47 yM1uxjMVDsuOXXcFMK5fDD7Q80gflq5ky2RG3DnPrefchf9XOYVK5elSoJ0IQt9JcChB xbiSU9N/mRahK3zk3jgBad14IyONVt1X1WrhLFbaOt8fv+yrYeQnTi7UhcQKwjlZpgR6 NYJA== X-Gm-Message-State: AC+VfDzP4Xgz7sEYmH9T5AFYFryZRX5MMsJ/VJ5Q2UYLBxsAs0LiuzBJ VRw8XO2dARoPD8T91e9eS1gpXLX5YtgFXXSYqeHIKg== X-Received: by 2002:a7b:c84c:0:b0:3f6:834:d33f with SMTP id c12-20020a7bc84c000000b003f60834d33fmr1475122wml.24.1685001955621; Thu, 25 May 2023 01:05:55 -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 i2-20020a05600c290200b003eddc6aa5fasm4756414wmd.39.2023.05.25.01.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:05:55 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Marc_Poulhi=C3=A8s?= Subject: [COMMITTED] ada: Fix (again) incorrect handling of Aggregate aspect Date: Thu, 25 May 2023 10:05:54 +0200 Message-Id: <20230525080554.1956654-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 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 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?1766853827983696081?= X-GMAIL-MSGID: =?utf-8?q?1766853827983696081?= Previous fix stopped the processing of the Aggregate aspect early, skipping the call to Record_Rep_Item, making later call to Resolve_Container_Aggregate fail. Also, the previous fix would not handle correctly the case where the type is private and the check for non-array type can only be done at the freeze point with the full type. Adapt the resolving of the aspect when the input is not correct and the parameters can't be resolved. gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Call Record_Rep_Item. (Check_Aspect_At_Freeze_Point): Check the aspect is specified on non-array type only... (Analyze_One_Aspect): ... instead of doing it too early here. * sem_aggr.adb (Resolve_Container_Aggregate): Do nothing in case the parameters failed to resolve. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 9 +++++++-- gcc/ada/sem_ch13.adb | 12 +++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index f1511b70648..33c44c42a24 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -3160,6 +3160,7 @@ package body Sem_Aggr is if Present (Add_Unnamed_Subp) and then No (New_Indexed_Subp) + and then Etype (Add_Unnamed_Subp) /= Any_Type then declare Elmt_Type : constant Entity_Id := @@ -3203,7 +3204,9 @@ package body Sem_Aggr is end if; end; - elsif Present (Add_Named_Subp) then + elsif Present (Add_Named_Subp) + and then Etype (Add_Named_Subp) /= Any_Type + then declare -- Retrieves types of container, key, and element from the -- specified insertion procedure. @@ -3245,7 +3248,9 @@ package body Sem_Aggr is end loop; end; - elsif Present (Assign_Indexed_Subp) then + elsif Present (Assign_Indexed_Subp) + and then Etype (Assign_Indexed_Subp) /= Any_Type + then -- Indexed Aggregate. Positional or indexed component -- can be present, but not both. Choices must be static -- values or ranges with static bounds. diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index a3819725181..6f9fe738ddd 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -4203,11 +4203,8 @@ package body Sem_Ch13 is Aitem := Empty; when Aspect_Aggregate => - if Is_Array_Type (E) then - Error_Msg_N - ("aspect% can only be applied to non-array type", Id); - goto Continue; - end if; + -- We will be checking that the aspect is not specified on a + -- non-array type in Check_Aspect_At_Freeze_Point Validate_Aspect_Aggregate (Expr); Record_Rep_Item (E, Aspect); @@ -11225,6 +11222,11 @@ package body Sem_Ch13 is return; when Aspect_Aggregate => + if Is_Array_Type (Entity (ASN)) then + Error_Msg_N + ("aspect% can only be applied to non-array type", + Identifier (ASN)); + end if; Resolve_Aspect_Aggregate (Entity (ASN), Expression (ASN)); return;