https://gcc.gnu.org/g:17e59eebf9ce02665a37cbeb51d9b4c2cf80d2ae

commit r16-4245-g17e59eebf9ce02665a37cbeb51d9b4c2cf80d2ae
Author: Marc Poulhiès <[email protected]>
Date:   Tue Sep 16 15:07:29 2025 +0200

    ada: Fix extended access and memory pool explicit deref
    
    Explicit dereference of an extended access with data allocation in a
    memory pool would crash the compiler.
    
    gcc/ada/ChangeLog:
    
            * gcc-interface/trans.cc (Attribute_to_gnu)<Attr_Pool_Address>: 
Handle
            extended access.

Diff:
---
 gcc/ada/gcc-interface/trans.cc | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index e80002e31113..cdbd4828c825 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -1937,12 +1937,17 @@ Attribute_to_gnu (Node_Id gnat_node, tree 
*gnu_result_type_p,
        tree gnu_ptr = gnu_prefix;
        tree gnu_obj_type;
 
-       gnu_result_type = get_unpadded_type (Etype (gnat_node));
-
-       /* If this is fat pointer, the object must have been allocated with the
-          template in front of the array.  So compute the template address; do
-          it by converting to a thin pointer.  */
-       if (TYPE_IS_FAT_POINTER_P (TREE_TYPE (gnu_ptr)))
+        if (Is_Extended_Access_Type (Etype (Prefix (gnat_node)))
+            && !Is_Constrained (Etype (gnat_node)))
+          gnu_result_type = get_unpadded_extended_type (Etype (gnat_node));
+        else
+          gnu_result_type = get_unpadded_type (Etype (gnat_node));
+
+       /* If this is fat or extended pointer, the object must have been
+          allocated with the template in front of the array.  So compute the
+          template address; do it by converting to a thin pointer.  */
+       if (TYPE_IS_FAT_POINTER_P (TREE_TYPE (gnu_ptr))
+            || TYPE_IS_EXTENDED_POINTER_P (TREE_TYPE (gnu_ptr)))
          gnu_ptr
            = convert (build_pointer_type
                       (TYPE_OBJECT_RECORD_TYPE

Reply via email to