From 4476d9345547473030a8a041d3178bb54ed49bef Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Wed, 10 Mar 2021 23:20:58 +0100 Subject: [PATCH] [Ada] Remove dubious wrapper of a recursive function gcc/ada/ * sem_util.adb (Is_Valid_Renaming): Body moved from its nested routine. --- gcc/ada/sem_util.adb | 94 ++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 54 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index c9d97a9..855195d 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -7294,70 +7294,56 @@ package body Sem_Util is ----------------------- function Is_Valid_Renaming (N : Node_Id) return Boolean is - function Check_Renaming (N : Node_Id) return Boolean; - -- Recursive function used to traverse all the prefixes of N - - -------------------- - -- Check_Renaming -- - -------------------- - - function Check_Renaming (N : Node_Id) return Boolean is - begin - if Is_Renaming (N) - and then not Check_Renaming (Renamed_Entity (Entity (N))) - then - return False; - end if; - - if Nkind (N) = N_Indexed_Component then - declare - Indx : Node_Id; - - begin - Indx := First (Expressions (N)); - while Present (Indx) loop - if not Is_OK_Static_Expression (Indx) then - return False; - end if; - - Next_Index (Indx); - end loop; - end; - end if; + begin + if Is_Renaming (N) + and then not Is_Valid_Renaming (Renamed_Entity (Entity (N))) + then + return False; + end if; - if Has_Prefix (N) then - declare - P : constant Node_Id := Prefix (N); + if Nkind (N) = N_Indexed_Component then + declare + Indx : Node_Id; - begin - if Nkind (N) = N_Explicit_Dereference - and then Is_Variable (P) - then + begin + Indx := First (Expressions (N)); + while Present (Indx) loop + if not Is_OK_Static_Expression (Indx) then return False; + end if; - elsif Is_Entity_Name (P) - and then Ekind (Entity (P)) = E_Function - then - return False; + Next_Index (Indx); + end loop; + end; + end if; - elsif Nkind (P) = N_Function_Call then - return False; - end if; + if Has_Prefix (N) then + declare + P : constant Node_Id := Prefix (N); + + begin + if Nkind (N) = N_Explicit_Dereference + and then Is_Variable (P) + then + return False; - -- Recursion to continue traversing the prefix of the - -- renaming expression + elsif Is_Entity_Name (P) + and then Ekind (Entity (P)) = E_Function + then + return False; - return Check_Renaming (P); - end; - end if; + elsif Nkind (P) = N_Function_Call then + return False; + end if; - return True; - end Check_Renaming; + -- Recursion to continue traversing the prefix of the + -- renaming expression - -- Start of processing for Is_Valid_Renaming + return Is_Valid_Renaming (P); + end; + end if; - begin - return Check_Renaming (N); + return True; end Is_Valid_Renaming; -- Local variables -- 2.7.4