Ada: Improve analysis and diagnostics for the Initialize aspect in constructors.
The compiler now better enforces and diagnoses issues related to the Initialize aspect in Ada constructors, preventing incorrect initialization order, flagging…
This patch enhances the analysis of the Initialize aspect within Ada constructor bodies. Assignments based on the Initialize aspect are now consistently placed at the end of the constructor prologue to prevent overwriting. The patch introduces an ‘others’ default choice for the Initialize aggregate, improves diagnostics for misspelled Initialize aspects, flags missing components requiring initialization, and checks for invalid references to ancestors in aggregate choices, thus ensuring more robust and correct object initialization.
In Details
The Initialize aspect in Ada allows specifying how an object's components should be initialized during construction. This patch modifies exp_ch3.adb, exp_ch6.adb, sem_ch13.adb, and sem_ch6.adb to improve the handling of this aspect, particularly within constructors.
For Context
In Ada, the Initialize aspect lets you specify how object components are initialized when a constructor runs. This commit improves how the compiler handles the Initialize aspect, ensuring assignments happen in the correct order and providing better error messages when things go wrong. By catching issues like missing initializations or incorrect references, the compiler helps ensure objects are correctly set up when they're created.