[Ada] Provide allocation subtype for allocators of a Designated_Storage_Model type
authorGary Dismukes <dismukes@adacore.com>
Fri, 25 Mar 2022 16:56:24 +0000 (12:56 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 17 May 2022 08:25:48 +0000 (08:25 +0000)
commit867bf6f087e9566339cecce358319603ecd08248
tree44272b8f08aca7e50f3b3506c501c60a571d9fa3
parentf2ef7a0545d1c17dd7e0ec8eb85b286d445dcc3f
[Ada] Provide allocation subtype for allocators of a Designated_Storage_Model type

When an allocator is for an access type that has a
Designated_Storage_Model aspect, and the designated type is an
unconstrained record type with discriminants, and the subtype associated
with the allocator is constrained, a dereference of the new access value
can be passed to the designated type's initialization procedure. The
post-front-end phase of the compiler needs to be able to create a
temporary object in the host memory space to pass to the init proc,
which requires creating such an object, but the subtype needed for the
allocation isn't readily available at the point of the dereference.  To
make the subtype easily accessible, we set the Actual_Designated_Subtype
of such a dereference to the subtype of the allocated object.

gcc/ada/

* exp_ch4.adb (Expand_N_Allocator): For an allocator with an
unconstrained discriminated designated type, and whose
allocation subtype is constrained, set the
Actual_Designated_Subtype of the dereference passed to the init
proc of the designated type to be the allocation subtype.
* sinfo.ads: Add documentation of new setting of
Actual_Designated_Subtype on a dereference used as an actual
parameter of call to an init proc associated with an allocator.
Also add missing syntax and documentation for the GNAT language
extension that allows an expression as a default for a concrete
generic formal function.
gcc/ada/exp_ch4.adb
gcc/ada/sinfo.ads