[Ada] Refine use of access types in unnesting
authorRichard Kenner <kenner@adacore.com>
Mon, 4 May 2020 13:47:30 +0000 (09:47 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 6 Jul 2020 11:34:59 +0000 (07:34 -0400)
gcc/ada/

* exp_unst.adb (Needs_Fat_Pointer): Don't check for formal.
(Unnest_Subprogram): Use 'Unchecked_Access instead of 'Access
when populating activation record.

gcc/ada/exp_unst.adb

index c922300f3d49a907e72cd4c6b75a16e36c889ad7..e530a94f32e5e499d1eee221b8a7d0bff2b7a4b3 100644 (file)
@@ -251,18 +251,14 @@ package body Exp_Unst is
    -----------------------
 
    function Needs_Fat_Pointer (E : Entity_Id) return Boolean is
-      Typ : Entity_Id;
-   begin
-      if Is_Formal (E) then
-         Typ := Etype (E);
-         if Is_Private_Type (Typ) and then Present (Full_View (Typ)) then
-            Typ := Full_View (Typ);
-         end if;
+      Typ : Entity_Id := Etype (E);
 
-         return Is_Array_Type (Typ) and then not Is_Constrained (Typ);
-      else
-         return False;
+   begin
+      if Is_Private_Type (Typ) and then Present (Full_View (Typ)) then
+         Typ := Full_View (Typ);
       end if;
+
+      return Is_Array_Type (Typ) and then not Is_Constrained (Typ);
    end Needs_Fat_Pointer;
 
    ----------------
@@ -2084,7 +2080,7 @@ package body Exp_Unst is
                                  --  or else 'Access for unconstrained array
 
                                  if Needs_Fat_Pointer (Ent) then
-                                    Attr := Name_Access;
+                                    Attr := Name_Unchecked_Access;
                                  else
                                     Attr := Name_Address;
                                  end if;