https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114300
--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- This should work on mainline: diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 640ad5c60b8..ee948e0934b 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -2522,7 +2522,11 @@ package body Exp_Ch7 is elsif Ekind (Obj_Id) = E_Variable and then Is_RTE (Obj_Typ, RE_Master_Node) then - Processing_Actions (Decl); + if not + Is_Ignored_Ghost_Entity (Finalization_Master_Node (Obj_Id)) + then + Processing_Actions (Decl); + end if; -- Ignored Ghost objects do not need any cleanup actions -- because they will not appear in the final tree.