ada: Another couple of cleanups in the finalization machinery
commit5a6dbb34c521e79ced35ce778bc86b39f3d348a7
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 2 Nov 2023 14:05:06 +0000 (2 15:05 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 21 Nov 2023 09:57:43 +0000 (21 10:57 +0100)
treef5a1f800c82084971137f9c54e59ddf4e735ef20
parent87517ca34eb1d65f33fd01e4e5e6fa900cb65f4b
ada: Another couple of cleanups in the finalization machinery

For package specs and bodies that need finalizers, Build_Finalizer is
invoked from the Standard scope so it needs to adjust the scope stack
before creating new objects; this changes it to do so only once.

For other kinds of scopes, it is invoked from Expand_Cleanup_Actions,
which assumes that the correct scope is already on the stack; that's
why Cleanup_Scopes adjusts the scope stack explicitly, but it should
use Pop_Scope instead of End_Scope to do it.

gcc/ada/

* exp_ch7.adb (Build_Finalizer): For package specs and bodies, push
and pop the specs onto the scope stack only once.
* inline.adb (Cleanup_Scopes): Call Pop_Scope instead of End_Scope.
gcc/ada/exp_ch7.adb
gcc/ada/inline.adb