public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-7898] ada: Fix assertion failure introduced by latest change
Date: Wed, 27 Sep 2023 08:27:50 +0000 (GMT)	[thread overview]
Message-ID: <20230927082750.C25D038654A3@sourceware.org> (raw)

https://gcc.gnu.org/g:82bf3afa68a4ba433a86d72e5386dec73938891a

commit r13-7898-g82bf3afa68a4ba433a86d72e5386dec73938891a
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed Jul 5 19:49:40 2023 +0200

    ada: Fix assertion failure introduced by latest change
    
    The new processing is not properly guarded.
    
    gcc/ada/
    
            * sem_ch13.adb (Replace_Type_References_Generic.Visible_Component):
            In the case of private discriminated types, explicitly check that we
            have a private declaration before examining its discriminant part.

Diff:
---
 gcc/ada/sem_ch13.adb | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index d66255cdd9e..b81b6b02e1d 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -15463,8 +15463,6 @@ package body Sem_Ch13 is
          elsif Is_Private_Type (T) and then Has_Discriminants (T) then
             declare
                Decl : constant Node_Id := Declaration_Node (T);
-               Spec : constant List_Id :=
-                 Discriminant_Specifications (Original_Node (Decl));
 
                Discr : Node_Id;
 
@@ -15474,8 +15472,11 @@ package body Sem_Ch13 is
                --  name; then, if it exists, return the discriminant entity of
                --  the same name in the type, which is that of its full view.
 
-               if Present (Spec) then
-                  Discr := First (Spec);
+               if Nkind (Decl) in N_Private_Extension_Declaration
+                                | N_Private_Type_Declaration
+                 and then Present (Discriminant_Specifications (Decl))
+               then
+                  Discr := First (Discriminant_Specifications (Decl));
 
                   while Present (Discr) loop
                      if Chars (Defining_Identifier (Discr)) = Comp then

                 reply	other threads:[~2023-09-27  8:27 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=20230927082750.C25D038654A3@sourceware.org \
    --to=ebotcazou@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).