public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-597] [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-cvs

https://gcc.gnu.org/g:9af8c27f090ae549f43e40cff00a9d702db0ac85

commit r13-597-g9af8c27f090ae549f43e40cff00a9d702db0ac85
Author: Marc Poulhiès <poulhies@adacore.com>
Date:   Mon Apr 4 14:09:45 2022 +0200

    [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.

Diff:
---
 gcc/ada/gen_il-gen-gen_nodes.adb |  1 +
 gcc/ada/par-ch4.adb              |  1 +
 gcc/ada/sem_aggr.adb             | 11 ++++++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb
index 7ebc02eb8d9..96e1c761d92 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 0895be10655..bfefd144f21 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 4796ae15ae2..e349128e6a2 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;


^ 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 [gcc r13-597] [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).