]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Clean up and restrict usage of Initialization_Statements
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 14 Nov 2024 19:33:34 +0000 (20:33 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 12 Dec 2024 09:57:54 +0000 (10:57 +0100)
commit9c399e7ef2dfae46b6abb34842a8769376f623c9
treedf8bb04750a11cee78e39a15260c3e2252e328b0
parent9420666b5a93e510f2f10470a000fd5b4f9401aa
ada: Clean up and restrict usage of Initialization_Statements

This mechanism is the only producer of N_Compound_Statement in the expanded
code and parks the statements generated for the in-place initialization of
objects by an aggregate, so that they can be moved to the freeze point if
there is an address aspect/clause, or even cancelled if the aggregate has
been generated for Initialize_Scalars/Normalize_Scalars before a subsequent
pragma Import for the object is encountered.

The main condition for its triggering is that the object be not yet frozen,
but that's always the case when its declaration is being processed, so the
mechanism is triggered unnecessarily and the change restricts this but, on
the other hand, it also extends its usage to the in-place initialization by
a function call, which was implemented by means of a custom deferral.

There should be no functional changes.

gcc/ada/ChangeLog:

* einfo.ads (Initialization_Statements): Document usage precisely.
* exp_aggr.adb (Convert_Aggr_In_Object_Decl): Do not create a
compound statement in most cases, do it only if necessary.
* exp_ch3.adb (Expand_N_Object_Declaration): Remove a couple of
useless statements.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Object_Declaration):
Use the Initialization_Statements mechanism if necessary.
* exp_ch7.adb: Remove clauses for Aspects package.
(Insert_Actions_In_Scope_Around): Use the support code of Exp_Util
for the Initialization_Statements mechanism.
* exp_prag.adb (Undo_Initialization): Remove obsolete code.
* exp_util.ads (Move_To_Initialization_Statements): New procedure.
(Needs_Initialization_Statements): New function.
* exp_util.adb (Move_To_Initialization_Statements): New procedure.
(Needs_Initialization_Statements): New predicate.
gcc/ada/einfo.ads
gcc/ada/exp_aggr.adb
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch6.adb
gcc/ada/exp_ch7.adb
gcc/ada/exp_prag.adb
gcc/ada/exp_util.adb
gcc/ada/exp_util.ads