[Ada] Implement late initialization rules for type extensions
commitb77029ff250b7a6b0a8f07aa0c4199adca2f4e91
authorSteve Baird <baird@adacore.com>
Wed, 9 Feb 2022 01:43:14 +0000 (8 17:43 -0800)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 13 May 2022 08:04:37 +0000 (13 08:04 +0000)
treec650c8bf1f23a0e35e71e18128d51fdcd9aac4f4
parent7b6fa643ef03f898a6e7284167fa6d064ba8b524
[Ada] Implement late initialization rules for type extensions

Default initialization of a record object is required to initialize any
components that "require late initialization" after other components.
This includes the case of a type extension; "late initialization"
components of the parent type are required to be initialized after
non-late-init extension components. This is implemented by generalizing
the use of an existing init proc parameter. Previously, the init proc
for a tagged type took a Boolean parameter indicating whether or not to
initialize the Tag component. With this change, this parameter can now
take on any of four values indicating whether to perform

   1) Full initialization (including the tag component).
   2) Full initialization except for the tag component.
   3) Early (non-tag) initialization only.
   4) Late (non-tag) initialization only.

With this change, the init proc for a type extension has the option of
performing the early and late portions of the parent's initialization
via two separate calls to the parent type's init proc.

gcc/ada/

* exp_ch3.ads (Build_Intialization_Call): Add new formal
parameter, Init_Control_Actual, with default value. Clients
outside of package Exp_Ch3 are unaffected.
* exp_ch3.adb (Initialization_Control): new package; support for
this 4-valued parameter.  The existing Requires_Late_Init
function is moved into this new package.
(Build_Initialization_Call): Add new formal parameter for
subprogram body, use this new formal parameter in generating an
init proc call.
(Build_Record_Init_Proc): Replace Set_Tag Boolean formal
parameter with 4-valued Init_Control_Formal. Wrap if-statements
with appropriate conditions around tag initialization, early
initialization, and late initialization statements.
* exp_util.adb (Build_Task_Image_Decl): Avoid problem with
duplicate declarations when an init proc for a type extension
calls the parent type's init proc twice.
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch3.ads
gcc/ada/exp_util.adb