[Ada] GNAT-LLVM unnesting issues in elaboration code
gcc/ada/
* exp_ch7.adb (Check_Unnesting_In_Decls_Or_Stmts): In the case
of an if-statement, call Unnest_If_Statement to determine
whether there are nested subprograms in any of the statement
lists of the "if" parts that require a wrapping procedure to
handle possible up-level refeferences.
(Unnest_Block): Call Check_Unnesting_In_Handlers to do unnesting
of subprograms in exception handlers of the block statement.
(Unnest_If_Statement): New procedure to traverse the parts of an
if-statement and create wrapper procedures as needed to
encapsulate nested subprograms that may make up-level
references.
(Check_Stmts_For_Subp_Unnesting): New support procedure in
Unnest_If_Statement to traverse a statement list looking for
top-level subprogram bodies that require wrapping inside a
procedure (via Unnest_Statement_List) as well as possibly having
other statements (block, loop, if) that may themselves require
an unnesting transformation (via
Check_Unnesting_In_Decls_Or_Stmts).
(Unnest_Statement_List): New support procedure to traverse the
statements of a statement list that contains subprogram bodies
at the top level and replace the statement list with a wrapper
procedure body encapsulating the statements and a call to the
procedure.