From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f6a6b9c079so1939425e9.1 for ; Thu, 25 May 2023 01:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1685001955; x=1687593955; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LyZqiVx1x1KiehDLGZjWby2X50kTwCqhS6Key9hL99w=; b=hWcnQ+BAMdXWaVVX6Ph0yL1H55ufxuqPtnmV68u2zWMAuofdjpnyFAAyOjG3L7fjbH U21bvxjs1EQHqe9171PstzPWxSyfh94anTXC1/OcBJZyDBmikNQYHnmDT/jHVWho63g6 Y7wKW3TT/W/X8qPY+8cudOeVi8bVG8iM/EpV4I0l6CQtebqp/7ktjfLDcBdY7n2S102M iCSNg1GrJQ/WG6dK2HRseK2KI26nUe3N7nWghry9H/CVOeQ82zU2CgOftUqwFS0EDgoJ jGLYLFp7pKaF6rtCWX4bnC7Pq7N5rHk+IFz+owVuI1SzkHU9fBV4v5FIu2S7mXot9pWz 6G+w== 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-Google-Smtp-Source: ACHHUZ5CP9+br14bLL0fl7zJN0v+NJ8rbqbRFPN6/R0aiv6OKONexRjc0xFdL4J0DKKhKmoDNHoxNA== 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) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: =?UTF-8?q?Marc=20Poulhi=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 Content-Transfer-Encoding: 8bit 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 List-Id: 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; -- 2.40.0