public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-597] [Ada] Fix the parsing for delta aggregate
Date: Wed, 18 May 2022 08:43:57 +0000 (GMT)	[thread overview]
Message-ID: <20220518084357.F11D63857827@sourceware.org> (raw)

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;


                 reply	other threads:[~2022-05-18  8:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220518084357.F11D63857827@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).