diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-10-28 09:13:33 +0100 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-11-12 14:00:53 +0100 |
commit | 524590a3606d773a7827ed469d80f5c8701e5dd8 (patch) | |
tree | 1c55c413ea088c65cc14fb693fcfb410cb2e2306 | |
parent | bb4a081156175cf7ac7a818c6a669d3f63ea0ad8 (diff) | |
download | gcc-524590a3606d773a7827ed469d80f5c8701e5dd8.zip gcc-524590a3606d773a7827ed469d80f5c8701e5dd8.tar.gz gcc-524590a3606d773a7827ed469d80f5c8701e5dd8.tar.bz2 |
ada: Fix internal error on instantiation of package with a nested ghost package
The instantiation triggers an internal error in Gigi because of a dangling
ghost entity created by the finalization machinery.
gcc/ada/ChangeLog:
PR ada/114300
* exp_ch7.adb (Attach_Object_To_Master_Node): Propagate the
Is_Ignored_Ghost_Entity flag from the finalization procedure.
(Build_Finalizer.Process_Declarations): Move up the test on
Is_Ignored_Ghost_Entity.
* exp_util.adb (Requires_Cleanup_Actions): Likewise.
-rw-r--r-- | gcc/ada/exp_ch7.adb | 17 | ||||
-rw-r--r-- | gcc/ada/exp_util.adb | 12 |
2 files changed, 17 insertions, 12 deletions
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index f6c2430..e7bf0bd 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -986,6 +986,11 @@ package body Exp_Ch7 is Set_Finalize_Address_For_Node (Master_Node, Fin_Id); + -- Propagate the Ghost policy from the procedure to the node + + Set_Is_Ignored_Ghost_Entity + (Master_Node, Is_Ignored_Ghost_Entity (Fin_Id)); + Insert_After_And_Analyze (Master_Node_Ins, Master_Node_Attach, Suppress => All_Checks); end Attach_Object_To_Master_Node; @@ -2529,6 +2534,12 @@ package body Exp_Ch7 is elsif Is_Ignored_For_Finalization (Obj_Id) then null; + -- Ignored Ghost objects do not need any cleanup actions + -- because they will not appear in the final tree. + + elsif Is_Ignored_Ghost_Entity (Obj_Id) then + null; + -- Conversely, if one of the above cases created a Master_Node, -- finalization actions are required for the associated object. @@ -2537,12 +2548,6 @@ package body Exp_Ch7 is then Processing_Actions (Decl); - -- Ignored Ghost objects do not need any cleanup actions - -- because they will not appear in the final tree. - - elsif Is_Ignored_Ghost_Entity (Obj_Id) then - null; - -- The object is of the form: -- Obj : [constant] Typ [:= Expr]; diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 970af54..df10891 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -13300,6 +13300,12 @@ package body Exp_Util is elsif Is_Ignored_For_Finalization (Obj_Id) then null; + -- Ignored Ghost objects do not need any cleanup actions because + -- they will not appear in the final tree. + + elsif Is_Ignored_Ghost_Entity (Obj_Id) then + null; + -- Conversely, if one of the above cases created a Master_Node, -- finalization actions are required for the associated object. @@ -13308,12 +13314,6 @@ package body Exp_Util is then return True; - -- Ignored Ghost objects do not need any cleanup actions because - -- they will not appear in the final tree. - - elsif Is_Ignored_Ghost_Entity (Obj_Id) then - null; - -- The object is of the form: -- Obj : [constant] Typ [:= Expr]; -- |