aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarc Poulhiès <poulhies@adacore.com>2023-03-06 12:15:13 +0100
committerMarc Poulhiès <poulhies@adacore.com>2023-05-25 09:44:17 +0200
commit3da0e4ae25f15949f87e74aa96a03b47e51a9ff3 (patch)
tree09216b1633a4b50d3d20f7094d7d3db6484c46b9 /gcc
parent845d4419da1abe839431af7e6bf5aaecec932486 (diff)
downloadgcc-3da0e4ae25f15949f87e74aa96a03b47e51a9ff3.zip
gcc-3da0e4ae25f15949f87e74aa96a03b47e51a9ff3.tar.gz
gcc-3da0e4ae25f15949f87e74aa96a03b47e51a9ff3.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_aggr.adb9
-rw-r--r--gcc/ada/sem_ch13.adb12
2 files changed, 14 insertions, 7 deletions
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index f1511b7..33c44c4 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 a381972..6f9fe73 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;