Add support for implicit parameterless constructors.
The Ada compiler now supports implicit parameterless constructors for tagged types.
This commit introduces support for implicit parameterless constructors in Ada. An implicit parameterless constructor is available when no other constructor is declared for a tagged type that has an ancestor with constructors. The implicit constructor calls the parent’s parameterless constructor through the Super aspect without arguments, simplifying object initialization.
In Details
This commit modifies aspects.ads, exp_ch3.adb, exp_ch6.adb, sem_ch13.adb, and sem_ch3.adb to implement implicit parameterless constructors. The Super aspect is made optional to allow for explicit calls to the parent parameterless constructor. Build_Implicit_Parameterless_Constructor is added to build the implicit constructor when no other constructors are defined but the type has an ancestor with constructors. This touches the semantics and expansion logic for Ada tagged types and inheritance.
For Context
In object-oriented programming, constructors are special functions that initialize objects when they are created. Ada now supports implicit parameterless constructors, which are automatically generated constructors that take no arguments. This feature simplifies the creation of objects in inheritance hierarchies by automatically calling the parent's constructor when no explicit constructor is defined.