]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Remove dubious wrapper of a recursive function
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 10 Mar 2021 22:20:58 +0000 (23:20 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 17 Jun 2021 14:32:14 +0000 (10:32 -0400)
gcc/ada/

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

gcc/ada/sem_util.adb

index c9d97a93464352dacfd885af8fc292c5da83fcf3..855195dd220123926f9578ccb77381f02c8ccd03 100644 (file)
@@ -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