This patch improve the analysis for the Initialize aspect in constructor bodies.
Specifically:
- Assignments based on the Initialize aspect are always placed at the end of the
constructor prologue, otherwise they could be overwritten depending on the
original order of components.
- Introduce the "others" default choice for the Initialize aggregate.
- Improve diagnostics when the Initialize aspect is clearly misspelled.
- Flag components that are required to be initialized but are missing from the
Initialize aspect.
- Check whether aggregate choices refer to ancestors, which is not allowed.
gcc/ada/ChangeLog:
* exp_ch3.adb (Build_Implicit_Parameterless_Constructor): Add Initialize
aspect with default others to trigger Initialize aspect analysis.
* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue): Fix
initialization order.
(Init_From_Initialize_Expression): Retrieve initialization expression or
the default one base on the Initialize aspect.
(Init_From_Default_Or_Constructor):. Retrieve initialization expression
based on the default one in the record initialization list or the init
procedure.
* sem_ch13.adb (Analyze_Aspect_Specifications): Add check for
missing components that require initialization, and add an
expression_with_action node to place ABE during resolution of
aggregates with function calls.
(Check_Constructor_Choices): Helper to check that the aggregate choices
do not refer to ancestors.
(Diagnose_Misplaced_Aspects): Improve diagnostics when it is a clear
misspelling of Initialize aspect.
* sem_ch6.adb (Analyze_Direct_Attribute_Definition): If missing, add a
compiler generated Initialize aspect with default others to trigger
Initialize analysis.