public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix the parsing for delta aggregate
@ 2022-05-18  8:43 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-18  8:43 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 487 bytes --]

In Ada 2022, delta aggregate must use parentheses not square brackets
except array delta aggregates.

Tested on x86_64-pc-linux-gnu, committed on trunk

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.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1756 bytes --]

diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb
--- 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
--- 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
--- 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;
 



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-18  8:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18  8:43 [Ada] Fix the parsing for delta aggregate Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).