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-836] [Ada] Fix expansion of aggregate for discriminated limited extension
Date: Mon, 30 May 2022 08:30:47 +0000 (GMT)	[thread overview]
Message-ID: <20220530083047.881E53815FE6@sourceware.org> (raw)

https://gcc.gnu.org/g:567bf44932542b8f861dc7880dba3273fb5838ce

commit r13-836-g567bf44932542b8f861dc7880dba3273fb5838ce
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Sat Apr 23 12:28:28 2022 +0200

    [Ada] Fix expansion of aggregate for discriminated limited extension
    
    The presence of the discriminants prevents the values associated with the
    components of the parent type from being put into the sub-aggregate built
    for the _Parent component.
    
    gcc/ada/
    
            * exp_aggr.adb (Expand_Record_Aggregate.Build_Back_End_Aggregate):
            Skip the discriminants at the start of the component list before
            looking for the components inherited from the parent in the case
            of a tagged extension.

Diff:
---
 gcc/ada/exp_aggr.adb | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 13be987b3e6..4828406647c 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -8474,11 +8474,21 @@ package body Exp_Aggr is
                   Parent_Name  : Node_Id;
 
                begin
-                  --  Remove the inherited component association from the
-                  --  aggregate and store them in the parent aggregate
-
                   First_Comp   := First (Component_Associations (N));
                   Parent_Comps := New_List;
+
+                  --  First skip the discriminants
+
+                  while Present (First_Comp)
+                    and then Ekind (Entity (First (Choices (First_Comp))))
+                                                               = E_Discriminant
+                  loop
+                     Next (First_Comp);
+                  end loop;
+
+                  --  Then remove the inherited component association from the
+                  --  aggregate and store them in the parent aggregate
+
                   while Present (First_Comp)
                     and then
                       Scope (Original_Record_Component


                 reply	other threads:[~2022-05-30  8:30 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=20220530083047.881E53815FE6@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).