aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarc Poulhiès <poulhies@adacore.com>2022-04-04 14:09:45 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-18 08:41:04 +0000
commit9af8c27f090ae549f43e40cff00a9d702db0ac85 (patch)
treeebc03672c474e4e32b5e5c9b41f6c03db4f5501a /gcc
parentdea655ad57bc17377c87306e0c538ad8c065493d (diff)
downloadgcc-9af8c27f090ae549f43e40cff00a9d702db0ac85.zip
gcc-9af8c27f090ae549f43e40cff00a9d702db0ac85.tar.gz
gcc-9af8c27f090ae549f43e40cff00a9d702db0ac85.tar.bz2
[Ada] Fix the parsing for delta aggregate
In Ada 2022, delta aggregate must use parentheses not square brackets except array delta aggregates. gcc/ada/ * gen_il-gen-gen_nodes.adb (Gen_IL.Gen.Gen_Nodes): Add Is_Homogeneous_Aggregate field for N_Delta_Aggregate nodes. * par-ch4.adb (P_Aggregate_Or_Paren_Expr): Minor reformatting. * sem_aggr.adb (Resolve_Delta_Aggregate): Reject square brackets for record aggregate. (Resolve_Record_Aggregate): Uniformise error message.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/gen_il-gen-gen_nodes.adb1
-rw-r--r--gcc/ada/par-ch4.adb1
-rw-r--r--gcc/ada/sem_aggr.adb11
3 files changed, 12 insertions, 1 deletions
diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb
index 7ebc02e..96e1c76 100644
--- a/gcc/ada/gen_il-gen-gen_nodes.adb
+++ b/gcc/ada/gen_il-gen-gen_nodes.adb
@@ -509,6 +509,7 @@ begin -- Gen_IL.Gen.Gen_Nodes
Cc (N_Delta_Aggregate, N_Subexpr,
(Sy (Expression, Node_Id, Default_Empty),
+ Sy (Is_Homogeneous_Aggregate, Flag),
Sy (Component_Associations, List_Id, Default_No_List)));
Cc (N_Extension_Aggregate, N_Subexpr,
diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
index 0895be1..bfefd14 100644
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -1682,6 +1682,7 @@ package body Ch4 is
case Start_Token is
when Tok_Left_Bracket =>
+
Set_Component_Associations (Aggregate_Node, Assoc_List);
Set_Is_Homogeneous_Aggregate (Aggregate_Node);
T_Right_Bracket;
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 4796ae1..e349128 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -3291,6 +3291,15 @@ package body Sem_Aggr is
if Is_Array_Type (Typ) then
Resolve_Delta_Array_Aggregate (N, Typ);
else
+
+ -- Delta aggregates for record types must use parentheses,
+ -- not square brackets.
+
+ if Is_Homogeneous_Aggregate (N) then
+ Error_Msg_N
+ ("delta aggregates for record types must use (), not '[']", N);
+ end if;
+
Resolve_Delta_Record_Aggregate (N, Typ);
end if;
@@ -4916,7 +4925,7 @@ package body Sem_Aggr is
if Nkind (N) = N_Aggregate
and then Is_Homogeneous_Aggregate (N)
then
- Error_Msg_N ("record aggregate must use () and not '[']", N);
+ Error_Msg_N ("record aggregate must use (), not '[']", N);
return;
end if;