aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_aggr.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/sem_aggr.adb')
-rw-r--r--gcc/ada/sem_aggr.adb29
1 files changed, 28 insertions, 1 deletions
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 31ce9ca..3a093d2 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -1052,7 +1052,7 @@ package body Sem_Aggr is
elsif Is_Array_Type (Typ) and then Null_Record_Present (N) then
Error_Msg_N ("null record forbidden in array aggregate", N);
- elsif Present (Find_Aspect (Typ, Aspect_Aggregate))
+ elsif Has_Aspect (Typ, Aspect_Aggregate)
and then Ekind (Typ) /= E_Record_Type
and then Ada_Version >= Ada_2022
then
@@ -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;
@@ -3746,7 +3763,17 @@ package body Sem_Aggr is
("'<'> in record delta aggregate is not allowed", Assoc);
else
Analyze_And_Resolve (Expression (Assoc), Comp_Type);
+
+ -- The expression must not be of a limited type; RM 4.3.1(17.4/5)
+
+ if Is_Limited_Type (Etype (Expression (Assoc))) then
+ Error_Msg_N
+ ("expression of a limited type in record delta aggregate " &
+ "is not allowed",
+ Expression (Assoc));
+ end if;
end if;
+
Next (Assoc);
end loop;
end Resolve_Delta_Record_Aggregate;