From c31cbf91a0e2740cb317a4339a62cebd1d633475 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Thu, 16 Dec 2021 16:15:00 +0100 Subject: [PATCH] [Ada] Simplify traversal in hooking of transient scopes gcc/ada/ * exp_ch7.adb (Process_Transients_In_Scope): Remove unnecessary initialization of Must_Hook; change Detect_Subprogram_Call from function to procedure; adapt caller. --- gcc/ada/exp_ch7.adb | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 367bd3d..8417018 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -6188,15 +6188,15 @@ package body Exp_Ch7 is Last_Object : Node_Id; Related_Node : Node_Id) is - Must_Hook : Boolean := False; + Must_Hook : Boolean; -- Flag denoting whether the context requires transient object -- export to the outer finalizer. function Is_Subprogram_Call (N : Node_Id) return Traverse_Result; - -- Determine whether an arbitrary node denotes a subprogram call + -- Return Abandon if arbitrary node denotes a subprogram call - procedure Detect_Subprogram_Call is - new Traverse_Proc (Is_Subprogram_Call); + function Has_Subprogram_Call is + new Traverse_Func (Is_Subprogram_Call); procedure Process_Transient_In_Scope (Obj_Decl : Node_Id; @@ -6216,7 +6216,6 @@ package body Exp_Ch7 is -- A regular procedure or function call if Nkind (N) in N_Subprogram_Call then - Must_Hook := True; return Abandon; -- Special cases @@ -6226,20 +6225,13 @@ package body Exp_Ch7 is -- of the call. elsif Is_Rewrite_Substitution (N) then - Detect_Subprogram_Call (Original_Node (N)); - - if Must_Hook then - return Abandon; - else - return OK; - end if; + return Has_Subprogram_Call (Original_Node (N)); -- Generalized indexing always involves a function call elsif Nkind (N) = N_Indexed_Component and then Present (Generalized_Indexing (N)) then - Must_Hook := True; return Abandon; -- Keep searching @@ -6476,8 +6468,8 @@ package body Exp_Ch7 is -- due to the possibility of abnormal call termination. else - Detect_Subprogram_Call (N); - Blk_Ins := Last_Object; + Must_Hook := Has_Subprogram_Call (N) = Abandon; + Blk_Ins := Last_Object; end if; if Clean then -- 2.7.4