[Ada] Iterate with procedural version of Next routine where possible
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 18 Mar 2020 22:57:10 +0000 (23:57 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 11 Jun 2020 09:53:52 +0000 (05:53 -0400)
2020-06-11  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* checks.adb, exp_ch7.adb, exp_ch9.adb, exp_smem.adb, lib.adb,
nlists.adb, sem.adb, sem_aggr.adb, sem_ch3.adb, sem_ch6.adb,
sem_ch8.adb, sem_dim.adb, sem_res.adb, sem_util.adb,
sem_warn.adb: Replace uses of Next function with procedure.

15 files changed:
gcc/ada/checks.adb
gcc/ada/exp_ch7.adb
gcc/ada/exp_ch9.adb
gcc/ada/exp_smem.adb
gcc/ada/lib.adb
gcc/ada/nlists.adb
gcc/ada/sem.adb
gcc/ada/sem_aggr.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_ch8.adb
gcc/ada/sem_dim.adb
gcc/ada/sem_res.adb
gcc/ada/sem_util.adb
gcc/ada/sem_warn.adb

index 641a5b28174caba348de06b04be9d3f8a5e6e5ef..808a419ae9ba2e19d7c981d1a1d52813122ecf68 100644 (file)
@@ -3531,7 +3531,7 @@ package body Checks is
 
          --  Move to next subscript
 
-         Sub := Next (Sub);
+         Next (Sub);
       end loop;
    end Apply_Subscript_Validity_Checks;
 
index ed4e8c570e639528814ad2238bee26e3045c0ba3..5eec472302a7d385b1a4b1668dc35897d43027c2 100644 (file)
@@ -2852,7 +2852,7 @@ package body Exp_Ch7 is
                      exit;
                   end if;
 
-                  Result := Next (Result);
+                  Next (Result);
                end loop;
 
                return Result;
@@ -2895,7 +2895,7 @@ package body Exp_Ch7 is
             if No_Initialization (Decl) then
                if No (Expression (Last_Init)) then
                   loop
-                     Last_Init := Next (Last_Init);
+                     Next (Last_Init);
                      exit when No (Last_Init);
                      exit when Nkind (Last_Init) = N_Object_Declaration
                        and then Nkind (Expression (Last_Init)) = N_Reference
index 3d417ff995cd45dafdee9d717efc3f7614b5104f..8d4bf233cf10ab10b9c50f11bc5d11fc6b6d8f72 100644 (file)
@@ -2130,7 +2130,7 @@ package body Exp_Ch9 is
             if Present (First_Formal (Iface_Op))
               and then Is_Controlling_Formal (First_Formal (Iface_Op))
             then
-               Iface_Op_Param := Next (Iface_Op_Param);
+               Next (Iface_Op_Param);
             end if;
 
             Wrapper_Param := First (Wrapper_Params);
@@ -2215,7 +2215,7 @@ package body Exp_Ch9 is
          if Is_Private_Primitive_Subprogram (Subp_Id)
            and then not Has_Controlling_Result (Subp_Id)
          then
-            Formal := Next (Formal);
+            Next (Formal);
          end if;
 
          while Present (Formal) loop
index 6755d72ec3e33de592d9d1ff559117f3de57b2e6..adce44a6ae431f72f75aa90dc978fa5ab1b9b590 100644 (file)
@@ -454,7 +454,7 @@ package body Exp_Smem is
 
       begin
          while Next (Nod) /= After loop
-            Nod := Next (Nod);
+            Next (Nod);
          end loop;
 
          return Nod;
index 3a42e02209e29e5a47d03b028449d0105eaac914..fd0f16731be17425e536de6b3ec999b52a3c167e 100644 (file)
@@ -1335,7 +1335,7 @@ package body Lib is
            and then (Nkind (Context_Item) /= N_With_Clause
                       or else Limited_Present (Context_Item))
          loop
-            Context_Item := Next (Context_Item);
+            Next (Context_Item);
          end loop;
 
          if Present (Context_Item) then
@@ -1359,7 +1359,7 @@ package body Lib is
                   Write_Eol;
                end if;
 
-               Context_Item := Next (Context_Item);
+               Next (Context_Item);
             end loop;
 
             Outdent;
index a51b191c8da760dee3256a83797448f6db7a45b5..874d144bf23bb12e12de7ec9ac8f0408aa1aa331 100644 (file)
@@ -243,7 +243,7 @@ package body Nlists is
             N := F;
             loop
                Set_List_Link (N, To);
-               N := Next (N);
+               Next (N);
                exit when No (N);
             end loop;
 
@@ -530,7 +530,7 @@ package body Nlists is
             loop
                Set_List_Link (N, LC);
                exit when N = L;
-               N := Next (N);
+               Next (N);
             end loop;
 
             if Present (Before) then
@@ -597,7 +597,7 @@ package body Nlists is
             loop
                Set_List_Link (N, LC);
                exit when N = L;
-               N := Next (N);
+               Next (N);
             end loop;
 
             if Present (After) then
@@ -699,7 +699,7 @@ package body Nlists is
       Node := First (List);
       while Present (Node) loop
          Result := Result + 1;
-         Node := Next (Node);
+         Next (Node);
       end loop;
 
       return Result;
@@ -756,7 +756,7 @@ package body Nlists is
 
          while Present (E) loop
             Append (New_Copy (E), NL);
-            E := Next (E);
+            Next (E);
          end loop;
 
          return NL;
@@ -784,7 +784,7 @@ package body Nlists is
                Append (New_Copy (E), NL);
             end if;
 
-            E := Next (E);
+            Next (E);
          end loop;
 
          return NL;
@@ -990,7 +990,7 @@ package body Nlists is
    begin
       N := Node;
       loop
-         N := Next (N);
+         Next (N);
          exit when not Nkind_In (N, N_Pragma, N_Null_Statement);
       end loop;
 
@@ -1040,7 +1040,7 @@ package body Nlists is
    begin
       Elmt := First (List);
       for J in 1 .. Index - 1 loop
-         Elmt := Next (Elmt);
+         Next (Elmt);
       end loop;
 
       return Elmt;
index 5a723f34a956585ebee735069f597ac9f2e6de57..39542ec7e7c91087124cb075ca1551cea1f28d3e 100644 (file)
@@ -2377,7 +2377,7 @@ package body Sem is
             Action (Lib_Unit);
          end if;
 
-         Context_Item := Next (Context_Item);
+         Next (Context_Item);
       end loop;
    end Walk_Withs_Immediate;
 
index a0f878442f448d317c1c97a16387f12c753eef6e..84695b4bf601708e500349248402368cf02978a7 100644 (file)
@@ -4170,7 +4170,7 @@ package body Sem_Aggr is
                   raise Unrecoverable_Error;
                end if;
 
-               Assoc := Next (Assoc);
+               Next (Assoc);
             end loop;
          end;
       end if;
index f38d6e798bab3194d7405c859699e35e27ebb08b..538796efcb91a2ca2221b9cffda4ce6b05349a5f 100644 (file)
@@ -1032,7 +1032,7 @@ package body Sem_Ch3 is
                Param := First (Parameter_Specifications (Def));
                while Present (Param) loop
                   Check_For_Premature_Usage (Parameter_Type (Param));
-                  Param := Next (Param);
+                  Next (Param);
                end loop;
             end if;
 
index e4374453efca4b918532f984b470a1630f94d568..576e33e6bb1224fe4c081a1e0adb78aec8376e33 100644 (file)
@@ -7340,10 +7340,10 @@ package body Sem_Ch6 is
          --  rest of the parameters.
 
          if not In_Scope then
-            Prim_Param := Next (Prim_Param);
+            Next (Prim_Param);
          end if;
 
-         Iface_Param := Next (Iface_Param);
+         Next (Iface_Param);
          while Present (Iface_Param) and then Present (Prim_Param) loop
             Iface_Id  := Defining_Identifier (Iface_Param);
             Iface_Typ := Find_Parameter_Type (Iface_Param);
index e8d5a90c23ef92e3bc0bb01d6603a7a95aaeff8e..e62be5599f897454ac83423995e5097e0b4c45ab 100644 (file)
@@ -7230,7 +7230,7 @@ package body Sem_Ch8 is
                return True;
             end if;
 
-            Clause := Next (Clause);
+            Next (Clause);
          end loop;
 
          return False;
index d2fae2761cacf3e363a8335600376b3752615e72..378f4492d5d4723776d4cfc89ddce53b3ba941da 100644 (file)
@@ -681,7 +681,7 @@ package body Sem_Dim is
       --  Skip the symbol expression when present
 
       if Present (Symbol_Expr) and then Num_Choices = 0 then
-         Expr := Next (Expr);
+         Next (Expr);
       end if;
 
       Position := Low_Position_Bound;
index acc997871a4ea9c5387a9e56e78ae71ae92e8642..71c9ed2b0f0383b1b0a0b220a7df5f8fc552add3 100644 (file)
@@ -4960,7 +4960,7 @@ package body Sem_Res is
             Expr := Next (First (Expressions (Disc_Exp)));
             if Present (Expr) then
                Check_Allocator_Discrim_Accessibility_Exprs (Expr, Alloc_Typ);
-               Expr := Next (Expr);
+               Next (Expr);
                if Present (Expr) then
                   Check_Allocator_Discrim_Accessibility_Exprs
                     (Expr, Alloc_Typ);
@@ -9276,7 +9276,7 @@ package body Sem_Res is
                      end loop;
                   end if;
 
-                  Alt := Next (Alt);
+                  Next (Alt);
                end loop;
             end;
          end if;
index 76eb6653fb10349390a103549d4127ee6095f82f..207d9d23ba1e264d1b1a273b7fe5d32cf7f699a6 100644 (file)
@@ -10169,7 +10169,7 @@ package body Sem_Util is
                return Entity (Expression (Assoc));
             end if;
 
-            Assoc := Next (Assoc);
+            Next (Assoc);
          end loop;
 
          return Empty;
@@ -13824,7 +13824,7 @@ package body Sem_Util is
               Defining_Identifier (Decl));
          end if;
 
-         Decl := Next (Decl);
+         Next (Decl);
       end loop;
    end Inspect_Deferred_Constant_Completion;
 
@@ -20661,7 +20661,7 @@ package body Sem_Util is
 
          while Present (E) loop
             Append (New_Copy_Tree (E), NL);
-            E := Next (E);
+            Next (E);
          end loop;
 
          return NL;
@@ -28309,7 +28309,7 @@ package body Sem_Util is
             begin
                for Idx in Result'Range loop
                   Result (Idx) := Chosen_Interval (Range_Or_Expr);
-                  Range_Or_Expr := Next (Range_Or_Expr);
+                  Next (Range_Or_Expr);
                end loop;
                pragma Assert (not Present (Range_Or_Expr));
                Check_Consistency (Result);
@@ -28492,7 +28492,7 @@ package body Sem_Util is
                   Count := Count + 1;  -- an ordinary expression or range
                end if;
 
-               Choice := Next (Choice);
+               Next (Choice);
             end loop;
             return Count;
          end Unmerged_Choice_Count;
@@ -28510,14 +28510,14 @@ package body Sem_Util is
                   while Present (Others_Choice) loop
                      Count := Count + 1;
                      Result (Count) := Chosen_Interval (Others_Choice);
-                     Others_Choice := Next (Others_Choice);
+                     Next (Others_Choice);
                   end loop;
                end;
             else
                Count := Count + 1;
                Result (Count) := Chosen_Interval (Choice);
             end if;
-            Choice := Next (Choice);
+            Next (Choice);
          end loop;
          pragma Assert (Count = Result'Last);
          Normalize_Interval_List (Result, Count);
index 9a4a4d05f2f50cb54e7ae54c7fa7996e9aa7ae64..8ca6175703177509172e8194e067dd69ef72978c 100644 (file)
@@ -4734,7 +4734,7 @@ package body Sem_Warn is
                               return;
                            end if;
 
-                           X := Next (X);
+                           Next (X);
                         end loop;
                      end if;
                   end if;