ada: Fix unnesting generated loops with nested finalization procedure
commita1c78073051327da96f2321234e71d302a6df671
authorMarc Poulhiès <poulhies@adacore.com>
Thu, 14 Sep 2023 11:32:05 +0000 (14 13:32 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 26 Sep 2023 11:43:18 +0000 (26 13:43 +0200)
treeb9dcf0080388de03b12157c5867fa04c75164dd0
parent52a7e4c75f16f9cd441a7a73142840f7c43c1224
ada: Fix unnesting generated loops with nested finalization procedure

The compiler can generate loops for creating array aggregates, for
example used during the initialization of variable. If the component
type of the array element requires finalization, the compiler also
creates a block and a nested procedure that need to be correctly
unnested if unnesting is enabled. During the unnesting transformation,
the scopes for these inner blocks need to be fixed and set to the
enclosing loop entity.

gcc/ada/

* exp_ch7.adb (Contains_Subprogram): Recursively search for subp
in loop's statements.
(Unnest_Loop)<Fixup_Inner_Scopes>: New.
(Unnest_Loop): Rename local variable for more clarity.
* exp_unst.ads: Refresh comment.
gcc/ada/exp_ch7.adb
gcc/ada/exp_unst.ads