diff mbox series

[Ada] Remove dubious wrapper of a recursive function

Message ID 20210617143311.GA10082@adacore.com
State New
Headers show
Series [Ada] Remove dubious wrapper of a recursive function | expand

Commit Message

Pierre-Marie de Rodat June 17, 2021, 2:33 p.m. UTC
Routine Is_Valid_Renaming was a wrapper subprogram that simply called
its nested function. Code cleanup; semantics is unaffected.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_util.adb (Is_Valid_Renaming): Body moved from its nested
	routine.
diff mbox series

Patch

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- 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