From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id E8714385780E; Wed, 13 Mar 2024 15:38:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8714385780E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710344338; bh=9+WwByWXB3QQhuzZczYcQr8NhUyT5W51vf2HFbyxjsM=; h=From:To:Subject:Date:From; b=ND7Uk0mL66OE4hjNKLrzIX+/KOgG8seBnzcOsjSdGHQhaRU082B0Fva1lRqGWEfbP TnE9lqgnHH82XpHPCUwvIPSBoBHFpMspOJ8jkegST6FMzCEe9tLT9JGcMc9G1wX99R 7iGxUPBps63dfanjafVFgNISYxYStRDNiSsOe2sY= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-8435] ada: Fix (again) incorrect handling of Aggregate aspect X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: bc97504e021fd8719fa6d9e31c311b38e87a3900 X-Git-Newrev: 6c8e7aa2ce1d51050c59c1492be2a29890d2c172 Message-Id: <20240313153858.E8714385780E@sourceware.org> Date: Wed, 13 Mar 2024 15:38:58 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6c8e7aa2ce1d51050c59c1492be2a29890d2c172 commit r13-8435-g6c8e7aa2ce1d51050c59c1492be2a29890d2c172 Author: Marc Poulhiès Date: Mon Mar 6 12:15:13 2023 +0100 ada: Fix (again) incorrect handling of Aggregate aspect 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. Diff: --- 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 3ebb30d64ed..8d8a26329b5 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -3157,6 +3157,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 := @@ -3200,7 +3201,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. @@ -3242,7 +3245,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 317c4841d87..073e8f9b0d8 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -4211,11 +4211,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); @@ -11148,6 +11145,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;