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 r12-1505] [Ada] Make Incomplete_Or_Partial_View independent of the context
Date: Wed, 16 Jun 2021 08:44:47 +0000 (GMT)	[thread overview]
Message-ID: <20210616084447.CE24D398A41C@sourceware.org> (raw)

https://gcc.gnu.org/g:e505bf515f59e9c914101fdbd45ffeda9b51040f

commit r12-1505-ge505bf515f59e9c914101fdbd45ffeda9b51040f
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed Feb 24 12:29:10 2021 +0100

    [Ada] Make Incomplete_Or_Partial_View independent of the context
    
    gcc/ada/
    
            * sem_util.adb (Incomplete_Or_Partial_View): Retrieve the scope of
            the parameter and use it to find its incomplete view, if any.

Diff:
---
 gcc/ada/sem_util.adb | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 9b2bf86e94e..65376b1e1a1 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -14625,6 +14625,8 @@ package body Sem_Util is
    --------------------------------
 
    function Incomplete_Or_Partial_View (Id : Entity_Id) return Entity_Id is
+      S : constant Entity_Id := Scope (Id);
+
       function Inspect_Decls
         (Decls : List_Id;
          Taft  : Boolean := False) return Entity_Id;
@@ -14693,7 +14695,13 @@ package body Sem_Util is
    begin
       --  Deferred constant or incomplete type case
 
-      Prev := Current_Entity_In_Scope (Id);
+      Prev := Current_Entity (Id);
+
+      while Present (Prev) loop
+         exit when Scope (Prev) = S;
+
+         Prev := Homonym (Prev);
+      end loop;
 
       if Present (Prev)
         and then (Is_Incomplete_Type (Prev) or else Ekind (Prev) = E_Constant)
@@ -14706,13 +14714,12 @@ package body Sem_Util is
       --  Private or Taft amendment type case
 
       declare
-         Pkg      : constant Entity_Id := Scope (Id);
-         Pkg_Decl : Node_Id := Pkg;
+         Pkg_Decl : Node_Id;
 
       begin
-         if Present (Pkg)
-           and then Is_Package_Or_Generic_Package (Pkg)
-         then
+         if Present (S) and then Is_Package_Or_Generic_Package (S) then
+            Pkg_Decl := S;
+
             while Nkind (Pkg_Decl) /= N_Package_Specification loop
                Pkg_Decl := Parent (Pkg_Decl);
             end loop;
@@ -14737,7 +14744,7 @@ package body Sem_Util is
             --  Taft amendment type. The incomplete view should be located in
             --  the private declarations of the enclosing scope.
 
-            elsif In_Package_Body (Pkg) then
+            elsif In_Package_Body (S) then
                return Inspect_Decls (Private_Declarations (Pkg_Decl), True);
             end if;
          end if;


                 reply	other threads:[~2021-06-16  8:44 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=20210616084447.CE24D398A41C@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).