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

commit r16-3973-gdc61789283a297102dbbdc140c635b02991a12c5
Author: Marc Poulhiès <poulh...@adacore.com>
Date:   Thu Apr 24 17:15:36 2025 +0200

    ada: Do not set Esize for Extended Accesses
    
    The size of an extended access is unknown at this stage, so leave Esize
    empty.
    
    gcc/ada/ChangeLog:
    
            * layout.adb (Layout_Type): Adjust comment and code extended
            accesses.

Diff:
---
 gcc/ada/layout.adb | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb
index 099ea49656d9..51facf6070da 100644
--- a/gcc/ada/layout.adb
+++ b/gcc/ada/layout.adb
@@ -248,13 +248,21 @@ package body Layout is
       end if;
 
       --  For access types, set size/alignment. This is system address size,
-      --  except for fat pointers (unconstrained array access types), where the
-      --  size is two times the address size, to accommodate the two pointers
-      --  that are required for a fat pointer (data and template). Note that
-      --  E_Access_Protected_Subprogram_Type is not an access type for this
-      --  purpose since it is not a pointer but is equivalent to a record. For
-      --  access subtypes, copy the size from the base type since Gigi
-      --  represents them the same way.
+      --  except for unconstrained array access types:
+      --
+      --   - fat pointers where the size is two times the address size, to
+      --     accommodate the two pointers that are required for a fat pointer
+      --     (data and template).
+      --
+      --   - extended access where the size is the size of an address (data
+      --     pointer) plus the size of the template. The template size can't be
+      --     computed yet (will be done in the code generator), leave it empty
+      --     for now.
+      --
+      --  Note that E_Access_Protected_Subprogram_Type is not an access type
+      --  for this purpose since it is not a pointer but is equivalent to a
+      --  record. For access subtypes, copy the size from the base type since
+      --  the code generator represents them the same way.
 
       if Is_Access_Type (E) then
          Desig_Type := Underlying_Type (Designated_Type (E));
@@ -301,7 +309,9 @@ package body Layout is
 
            and then not Debug_Flag_6
          then
-            Init_Size (E, 2 * System_Address_Size);
+            if not Is_Extended_Access_Type (E) then
+               Init_Size (E, 2 * System_Address_Size);
+            end if;
 
             --  Check for bad convention set
 
@@ -326,7 +336,9 @@ package body Layout is
                                              N_Unconstrained_Array_Definition
            and then not Debug_Flag_6
          then
-            Init_Size (E, 2 * System_Address_Size);
+            if not Is_Extended_Access_Type (E) then
+               Init_Size (E, 2 * System_Address_Size);
+            end if;
 
          --  If unnesting subprograms, subprogram access types contain the
          --  address of both the subprogram and an activation record. But if we

Reply via email to