public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jiu Fu Guo <guojiufu@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/guojiufu/heads/guojiufu-branch)] [Ada] Fix small oversight in latest change for Replace_Discriminants
Date: Wed, 10 Jun 2020 03:22:41 +0000 (GMT)	[thread overview]
Message-ID: <20200610032241.7CEE8395704F@sourceware.org> (raw)

https://gcc.gnu.org/g:663091bc782563d7d9adc8b09e58afbac3656d13

commit 663091bc782563d7d9adc8b09e58afbac3656d13
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri Dec 13 16:57:46 2019 +0100

    [Ada] Fix small oversight in latest change for Replace_Discriminants
    
    2020-06-02  Eric Botcazou  <ebotcazou@adacore.com>
    
    gcc/ada/
    
            * sem_ch3.adb (Replace_Discriminants): Preserve the Etype of the
            Name of N_Variant_Part nodes when rewriting it.

Diff:
---
 gcc/ada/sem_ch3.adb | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index e792072b45f..3fa2dd8e7a1 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -22334,7 +22334,18 @@ package body Sem_Ch3 is
                if Original_Record_Component (Comp) = Entity (Name (N))
                  or else Chars (Comp) = Chars (Name (N))
                then
-                  Set_Name (N, New_Occurrence_Of (Comp, Sloc (N)));
+                  --  Make sure to preserve the type coming from the parent on
+                  --  the Name, even if the subtype of the discriminant can be
+                  --  constrained, so that discrete choices inherited from the
+                  --  parent in the variant part are not flagged as violating
+                  --  the constraints of the subtype.
+
+                  declare
+                     Typ : constant Entity_Id := Etype (Name (N));
+                  begin
+                     Rewrite (Name (N), New_Occurrence_Of (Comp, Sloc (N)));
+                     Set_Etype (Name (N), Typ);
+                  end;
                   exit;
                end if;


                 reply	other threads:[~2020-06-10  3:22 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=20200610032241.7CEE8395704F@sourceware.org \
    --to=guojiufu@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).