gnu/gcc/37ebb43231ca61e65364128baafcc0dec89ac08f ada: Fix support for initialization of components in constructors
Enforce the following rule: If the component of a record type is of
a type that doesn't have a parameterless constructor, it has to be
initialized by one of these two mechanism: 1) through the default
value provided at component declaration, or 2) through an Initialize
aspect that can rely on constructor parameters.
Enforce the following rule: a constructor for a derived type whose
parent type needs construction and has no default parameterless
constructor must call the parent constructor through a Super aspect
to initialize its parent components.
Fix order of initialization of derived record type components.
gcc/ada/ChangeLog:
* sem_ch6.adb (Constructor_Components_OK): New local subprogram of
Analyze_Direct_Attribute_Definition. Checks performed when processing
the body of a constructor.
(Analyze_Direct_Attribute_Definition) <Name_Constructor>: Report an
error on the body of a constructor for a derived type whose parent
type needs construction and has no default parameterless constructor
and has no Super aspect to initialize its parent components.
* sem_ch7.adb (Inspect_Components_Needing_Construction): New local
subprogram of Analyze_Package_Specification.
(Inspect_Abstract_Constructors_Completion): Rename formal parameter.
* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue): Fix the order
of initialization of record type components: parent components must
be initialized first, then the own components following their
declaration order.
* sem_util.ads (First_Component_Declaration): New subprogram.
* sem_util.adb (First_Component_Declaration): New utility subprogram
that returns the first non-pragma non-inherited component declaration
of a record type.
5 files changed