]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Initial support for Extended Access types
authorMarc Poulhiès <poulhies@adacore.com>
Tue, 15 Jul 2025 09:44:56 +0000 (11:44 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 19 Sep 2025 09:26:11 +0000 (11:26 +0200)
commit6eb4909a31bef2a05a8666b7d9cdd25824e1a37e
tree4f8c9ba2803c4c783709a83693dde45f0498945d
parent7d0480803651f2765c21c2b1082a5d8078187740
ada: Initial support for Extended Access types

This change introduces the support for the new GNAT specific
Extended_Access aspect for access to unconstrained array type :

  type Ext_Access is access all Some_Array_Type with Extended_Access;

 This new kind of access type does not use the existing "fat" layout with
 a record of two pointers: one to the actual data, one to a record with the
 bounds of the array. Instead, it removes the second indirection and extends
 the record to contain the pointer to the actual data followed by the bounds.

This mainly allows the following features:
- have access to slice of array
- easier interface when allocation is done in a foreign language

gcc/ada/ChangeLog:

* gcc-interface/ada-tree.h (TYPE_EXTENDED_POINTER_P): New.
(TYPE_IS_EXTENDED_POINTER_P): New.
(TYPE_EXTENDED_UNCONSTRAINED_ARRAY): New.
(SET_TYPE_EXTENDED_UNCONSTRAINED_ARRAY): New.
(TYPE_DUMMY_EXT_POINTER_TO): New.
(SET_TYPE_DUMMY_EXT_POINTER_TO): New.
* gcc-interface/decl.cc (get_extended_unconstrained_array): New.
(gnat_to_gnu_entity): Handle extended access type.
(get_unpadded_extended_type): New.
(gnat_to_gnu_component_type): Handle extended access type.
(build_template_type): New.
(gnat_to_gnu_field): Handle extended access type.
(validate_size): Likewise.
(set_rm_size): Likewise.
(copy_and_substitute_in_layout): Likewise.
(rm_size): Likewise.
* gcc-interface/gigi.h (get_unpadded_extended_type): New.
(build_template_type): New.
(build_dummy_unc_pointer_types_ext): New.
(finish_extended_pointer_type): New.
(build_unc_object_type_from_ptr): Rename first parameter.
* gcc-interface/misc.cc (gnat_print_type): Handle extended access type.
* gcc-interface/trans.cc (Identifier_to_gnu): Likewise.
(Attribute_to_gnu): Likewise.
(gnat_to_gnu): Likewise.
* gcc-interface/utils.cc (convert_to_fat_pointer): Assert if converting an
extended pointer.
(build_dummy_unc_pointer_types_ext): New.
(finish_extended_pointer_type): New.
(finish_record_type): Handle extended access type.
(build_unc_object_type_from_ptr): Likewise.
(convert_to_extended_pointer): New.
(convert): Handle extended access type.
(gnat_pushdecl): Likewise.
(maybe_pad_type): Likewise.
* gcc-interface/utils2.cc (build_unary_op): Likewise.
(build_binary_op): Likewise.
(build_allocator): Likewise.
(gnat_save_expr): Likewise.
(gnat_protect_expr): Likewise.
(gnat_stabilize_reference_1): Likewise.
gcc/ada/gcc-interface/ada-tree.h
gcc/ada/gcc-interface/decl.cc
gcc/ada/gcc-interface/gigi.h
gcc/ada/gcc-interface/misc.cc
gcc/ada/gcc-interface/trans.cc
gcc/ada/gcc-interface/utils.cc
gcc/ada/gcc-interface/utils2.cc