From: Marc Poulhiès Date: Tue, 16 Sep 2025 13:07:29 +0000 (+0200) Subject: ada: Fix extended access and memory pool explicit deref X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17e59eebf9ce02665a37cbeb51d9b4c2cf80d2ae;p=thirdparty%2Fgcc.git 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): Handle extended access. --- diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index e80002e3111..cdbd4828c82 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