public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] [Ada] Fix fallout of cleanup to Has_Private_View mechanism
@ 2020-08-22 21:58 Giuliano Belinassi
  0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 21:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:976b165afe55167abefcf86a38cdb6c8d13d29d7

commit 976b165afe55167abefcf86a38cdb6c8d13d29d7
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Sat Jan 18 23:40:05 2020 +0100

    [Ada] Fix fallout of cleanup to Has_Private_View mechanism
    
    2020-06-04  Eric Botcazou  <ebotcazou@adacore.com>
    
    gcc/ada/
    
            * sem_ch12.adb (Check_Generic_Actuals): Also restore the proper
            views of the actuals of the parent instances if the formals are
            used as actuals of the children.
            (Instantiate_Type): Add comment.

Diff:
---
 gcc/ada/sem_ch12.adb | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index bb49e8388b5..23ee796b455 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -6802,8 +6802,35 @@ package body Sem_Ch12 is
            and then Scope (Etype (E)) /= Instance
            and then Is_Entity_Name (Subtype_Indication (Parent (E)))
          then
+            --  Restore the proper view of the actual from the information
+            --  saved earlier by Instantiate_Type.
+
             Check_Private_View (Subtype_Indication (Parent (E)));
 
+            --  If the actual is itself the formal of a parent instance,
+            --  then also restore the proper view of its actual and so on.
+            --  That's necessary for nested instantiations of the form
+
+            --    generic
+            --      type Component is private;
+            --      type Array_Type is array (Positive range <>) of Component;
+            --    procedure Proc;
+
+            --  when the outermost actuals have inconsistent views, because
+            --  the Component_Type of Array_Type of the inner instantiations
+            --  is the actual of Component of the outermost one and not that
+            --  of the corresponding inner instantiations.
+
+            Astype := Ancestor_Subtype (E);
+            while Present (Astype)
+              and then Nkind (Parent (Astype)) = N_Subtype_Declaration
+              and then Present (Generic_Parent_Type (Parent (Astype)))
+              and then Is_Entity_Name (Subtype_Indication (Parent (Astype)))
+            loop
+               Check_Private_View (Subtype_Indication (Parent (Astype)));
+               Astype := Ancestor_Subtype (Astype);
+            end loop;
+
             Set_Is_Generic_Actual_Type (E);
 
             if Is_Private_Type (E) and then Present (Full_View (E)) then
@@ -13603,6 +13630,10 @@ package body Sem_Ch12 is
           Defining_Identifier => Subt,
           Subtype_Indication  => New_Occurrence_Of (Act_T, Loc));
 
+      --  Record whether the actual is private at this point, so that
+      --  Check_Generic_Actuals can restore its proper view before the
+      --  semantic analysis of the instance.
+
       if Is_Private_Type (Act_T) then
          Set_Has_Private_View (Subtype_Indication (Decl_Node));
       end if;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-22 21:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 21:58 [gcc/devel/autopar_devel] [Ada] Fix fallout of cleanup to Has_Private_View mechanism Giuliano Belinassi

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).