]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Handle new At_End expansion during unnesting
authorJustin Squirek <squirek@adacore.com>
Thu, 18 Aug 2022 19:48:22 +0000 (19:48 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 6 Sep 2022 07:14:22 +0000 (09:14 +0200)
This patch modifies the marking of nested subprograms requiring static links,
so that the changes made to "At end" procedures get handled properly.

gcc/ada/

* exp_unst.adb
(Visit_Node): Add N_Block_Statement to the enclosing construct
case since they can now have "At end" procedures. Also, recognize
calls from "At end" procedures when recording subprograms.

gcc/ada/exp_unst.adb

index 2fb929908401fd1974104b6294d4f251959debbc..1297f289f7809220ca31fb2555cd817e17a530e8 100644 (file)
@@ -938,7 +938,7 @@ package body Exp_Unst is
                --  subprogram. As above, the called entity must be local and
                --  not imported.
 
-               when N_Handled_Sequence_Of_Statements =>
+               when N_Handled_Sequence_Of_Statements | N_Block_Statement =>
                   if Present (At_End_Proc (N))
                     and then Scope_Within (Entity (At_End_Proc (N)), Subp)
                     and then not Is_Imported (Entity (At_End_Proc (N)))
@@ -1184,6 +1184,15 @@ package body Exp_Unst is
 
                   Register_Subprogram (Ent, N);
 
+                  --  Record a call from an At_End_Proc
+
+                  if Present (At_End_Proc (N))
+                    and then Scope_Within (Entity (At_End_Proc (N)), Subp)
+                    and then not Is_Imported (Entity (At_End_Proc (N)))
+                  then
+                     Append_Unique_Call ((N, Ent, Entity (At_End_Proc (N))));
+                  end if;
+
                   --  We make a recursive call to scan the subprogram body, so
                   --  that we can save and restore Current_Subprogram.