]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Iterate with procedural versions of Next_... routines where possible
authorPiotr Trojanek <trojanek@adacore.com>
Sun, 5 Jan 2020 22:53:42 +0000 (23:53 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 3 Jun 2020 10:01:30 +0000 (06:01 -0400)
2020-06-03  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* checks.adb, einfo.adb, exp_aggr.adb, exp_ch4.adb, exp_ch6.adb,
exp_unst.adb, exp_util.adb, freeze.adb, inline.adb, repinfo.adb,
sem_aggr.adb, sem_attr.adb, sem_aux.adb, sem_ch13.adb,
sem_ch3.adb, sem_ch4.adb, sem_ch8.adb, sem_elab.adb,
sem_eval.adb, sem_prag.adb, sem_res.adb, sem_smem.adb,
sem_util.adb, treepr.adb: Replace uses of Next_ functions with
corresponding procedures.

24 files changed:
gcc/ada/checks.adb
gcc/ada/einfo.adb
gcc/ada/exp_aggr.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_ch6.adb
gcc/ada/exp_unst.adb
gcc/ada/exp_util.adb
gcc/ada/freeze.adb
gcc/ada/inline.adb
gcc/ada/repinfo.adb
gcc/ada/sem_aggr.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_aux.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch4.adb
gcc/ada/sem_ch8.adb
gcc/ada/sem_elab.adb
gcc/ada/sem_eval.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_res.adb
gcc/ada/sem_smem.adb
gcc/ada/sem_util.adb
gcc/ada/treepr.adb

index a2fa7d099ce1ba41e186064446cd59249208838b..c1744208e5934dd099e4c5b9afc3cd614b5e3604 100644 (file)
@@ -4889,7 +4889,7 @@ package body Checks is
 
                      Indx := First_Index (Atyp);
                      for J in 2 .. Inum loop
-                        Indx := Next_Index (Indx);
+                        Next_Index (Indx);
                      end loop;
 
                      --  If the index type is a formal type or derived from
@@ -6847,7 +6847,7 @@ package body Checks is
                       Reason => CE_Index_Check_Failed));
                end if;
 
-               A_Idx := Next_Index (A_Idx);
+               Next_Index (A_Idx);
                Ind := Ind + 1;
                Next (Sub);
             end loop;
index 9e7476c18ebc5dbadff854277362fe47419b5d7f..5c2b47bcffbf48b52c2a30b7742e15034b2cc445 100644 (file)
@@ -7405,7 +7405,7 @@ package body Einfo is
       Comp_Id := First_Entity (Id);
       while Present (Comp_Id) loop
          exit when Ekind (Comp_Id) = E_Component;
-         Comp_Id := Next_Entity (Comp_Id);
+         Next_Entity (Comp_Id);
       end loop;
 
       return Comp_Id;
@@ -7428,7 +7428,7 @@ package body Einfo is
       Comp_Id := First_Entity (Id);
       while Present (Comp_Id) loop
          exit when Ekind_In (Comp_Id, E_Component, E_Discriminant);
-         Comp_Id := Next_Entity (Comp_Id);
+         Next_Entity (Comp_Id);
       end loop;
 
       return Comp_Id;
@@ -7755,7 +7755,7 @@ package body Einfo is
             return True;
          end if;
 
-         Ent := Next_Entity (Ent);
+         Next_Entity (Ent);
       end loop;
 
       return False;
@@ -8540,7 +8540,7 @@ package body Einfo is
       Comp_Id := Next_Entity (Id);
       while Present (Comp_Id) loop
          exit when Ekind (Comp_Id) = E_Component;
-         Comp_Id := Next_Entity (Comp_Id);
+         Next_Entity (Comp_Id);
       end loop;
 
       return Comp_Id;
@@ -8557,7 +8557,7 @@ package body Einfo is
       Comp_Id := Next_Entity (Id);
       while Present (Comp_Id) loop
          exit when Ekind_In (Comp_Id, E_Component, E_Discriminant);
-         Comp_Id := Next_Entity (Comp_Id);
+         Next_Entity (Comp_Id);
       end loop;
 
       return Comp_Id;
@@ -8590,7 +8590,7 @@ package body Einfo is
       pragma Assert (Ekind (Id) = E_Discriminant);
 
       loop
-         D := Next_Entity (D);
+         Next_Entity (D);
          if No (D)
            or else (Ekind (D) /= E_Discriminant
                       and then not Is_Itype (D))
@@ -8715,7 +8715,7 @@ package body Einfo is
             N := N + 1;
          end if;
 
-         Ent := Next_Entity (Ent);
+         Next_Entity (Ent);
       end loop;
 
       return N;
@@ -8734,7 +8734,7 @@ package body Einfo is
       Formal := First_Formal (Id);
       while Present (Formal) loop
          N := N + 1;
-         Formal := Next_Formal (Formal);
+         Next_Formal (Formal);
       end loop;
 
       return N;
index 192ac99493b68cc05d5409ffa1074a7bab8cccdf..7805c2d8f85b904326ab04044da49182924afee6 100644 (file)
@@ -7227,7 +7227,7 @@ package body Exp_Aggr is
 
                   Comp := First_Component (Typ);
                   while Chars (Comp) /= Name_uParent loop
-                     Comp := Next_Component (Comp);
+                     Next_Component (Comp);
                   end loop;
 
                   Parent_Name := New_Occurrence_Of (Comp, Loc);
@@ -7364,7 +7364,7 @@ package body Exp_Aggr is
                         return False;
                      end if;
 
-                     Indx := Next_Index (Indx);
+                     Next_Index (Indx);
                   end loop;
                end if;
             end;
@@ -8888,12 +8888,12 @@ package body Exp_Aggr is
                   Comp_Val := Comp_Val mod Uint_2 ** Comp_Size;
                   Val := UI_To_Int (Val + Comp_Val * Uint_2 ** Shift);
                   Shift := Shift + Incr;
-                  One_Comp := Next (One_Comp);
+                  Next (One_Comp);
                   Packed_Num := Packed_Num + 1;
                end if;
             end loop;
 
-            One_Dim := Next (One_Dim);
+            Next (One_Dim);
          end loop;
 
          if Packed_Num > 0 then
index 2d63f7ee04b1240e1547bc3fc21e6999aed8e44a..66ebc531af7613d6828630e6639d102b7b224423 100644 (file)
@@ -7904,7 +7904,7 @@ package body Exp_Ch4 is
                if Is_Equality (E, Typ) then
                   return E;
                end if;
-               E := Next_Entity (E);
+               Next_Entity (E);
             end loop;
          end loop;
 
index bc05b515e03d61631e893e713d9a455098979f25..cc9c6e3c15e67fb24948edd1d9c300a7e5f616b5 100644 (file)
@@ -9636,7 +9636,7 @@ package body Exp_Ch6 is
 
       Last_Formal := First_Formal (Proc_Id);
       while Present (Next_Formal (Last_Formal)) loop
-         Last_Formal := Next_Formal (Last_Formal);
+         Next_Formal (Last_Formal);
       end loop;
 
       Actuals := Parameter_Associations (N);
index 02d3a754887d64e6400ae5819982457168d28b11..ade5fe0cfacd18d4368a5ca60ae6c1915afc2c43 100644 (file)
@@ -2104,7 +2104,7 @@ package body Exp_Unst is
 
                                     Comp := First_Component (STJ.ARECnT);
                                     while Chars (Comp) /= Chars (Ent) loop
-                                       Comp := Next_Component (Comp);
+                                       Next_Component (Comp);
                                     end loop;
 
                                     Rhs :=
index 5fd224be580c0a5efcb55afab6653583204ecc4f..1f3cfcc12748c031a1acd1b594db21787b6f15cc 100644 (file)
@@ -9549,7 +9549,7 @@ package body Exp_Util is
                       (Next (First (Pragma_Argument_Associations (Item))));
                end if;
 
-               Item := Next_Rep_Item (Item);
+               Next_Rep_Item (Item);
             end loop;
 
             return Empty;
@@ -9834,7 +9834,7 @@ package body Exp_Util is
                 Low_Bound  => New_Occurrence_Of (Low_Bound,  Loc),
                 High_Bound => New_Occurrence_Of (High_Bound, Loc)));
 
-            Index_Typ := Next_Index (Index_Typ);
+            Next_Index (Index_Typ);
          end loop;
 
       elsif Is_Class_Wide_Type (Unc_Typ) then
index a7822ed32e7a86768e767bc5cd45defc6b6dfd4e..673756fb507efaae6a06a27a8758070338f7ed48 100644 (file)
@@ -652,7 +652,7 @@ package body Freeze is
                   while Present (Rep)
                     and then Next_Rep_Item (Rep) /= Addr
                   loop
-                     Rep := Next_Rep_Item (Rep);
+                     Next_Rep_Item (Rep);
                   end loop;
                end if;
 
@@ -1957,7 +1957,7 @@ package body Freeze is
                         Check_Aspect_At_End_Of_Declarations (Ritem);
                      end if;
 
-                     Ritem := Next_Rep_Item (Ritem);
+                     Next_Rep_Item (Ritem);
                   end loop;
                end;
             end if;
index 68cf102a1dabbe3ea5799460b9083f82113875e3..b6e6a27d1859b4d4f70b9c0b02937294b7c83332 100644 (file)
@@ -852,7 +852,7 @@ package body Inline is
             return;
          end if;
 
-         Elmt := Next_Elmt (Elmt);
+         Next_Elmt (Elmt);
       end loop;
 
       Append_Elmt (Scop, To_Clean);
@@ -2787,7 +2787,7 @@ package body Inline is
          Expand_Cleanup_Actions (Decl);
          End_Scope;
 
-         Elmt := Next_Elmt (Elmt);
+         Next_Elmt (Elmt);
       end loop;
    end Cleanup_Scopes;
 
index 84c0badd06f112478e52489f7f2d869bb5283ad3..d02214c5063d6580bd22ba1e5e05171bfbe8c4d4 100644 (file)
@@ -600,7 +600,7 @@ package body Repinfo is
                end if;
             end if;
 
-            E := Next_Entity (E);
+            Next_Entity (E);
          end loop;
 
          --  For a package body, the entities of the visible subprograms are
index aec14c4cde3fbc56281715272d6bc37d5441adcd..1f2fd5995d9ee5664b9579cbf8ffdb23dddd0c0d 100644 (file)
@@ -3014,7 +3014,7 @@ package body Sem_Aggr is
                return Etype (Comp);
             end if;
 
-            Comp := Next_Entity (Comp);
+            Next_Entity (Comp);
          end loop;
 
          Error_Msg_NE ("type& has no component with this name", Nam, Typ);
index 7e3b64bdecc56fb9d4579f2903493186d5dfcef3..79ba4c45ea077d05978db1870c7417e87bb5ddd4 100644 (file)
@@ -6418,7 +6418,7 @@ package body Sem_Attr is
                      end if;
                   end if;
 
-                  Rep := Next_Rep_Item (Rep);
+                  Next_Rep_Item (Rep);
                end loop;
             end if;
          end Compute_Type_Key;
@@ -6760,7 +6760,7 @@ package body Sem_Attr is
                   exit;
                end if;
 
-               Comp_Or_Discr := Next_Entity (Comp_Or_Discr);
+               Next_Entity (Comp_Or_Discr);
             end loop;
 
             --  Diagnose an illegal reference
index 7da41a0ccec1b7f3e8008e6a499476d7a8e7b6c9..63e94b4cbb1dde99c355dd3f5c7f906635c1d154 100644 (file)
@@ -234,7 +234,7 @@ package body Sem_Aux is
       --  either because the tag must be ahead of them.
 
       if Chars (Ent) = Name_uTag then
-         Ent := Next_Entity (Ent);
+         Next_Entity (Ent);
       end if;
 
       --  Skip all hidden stored discriminants if any
@@ -243,7 +243,7 @@ package body Sem_Aux is
          exit when Ekind (Ent) = E_Discriminant
            and then not Is_Completely_Hidden (Ent);
 
-         Ent := Next_Entity (Ent);
+         Next_Entity (Ent);
       end loop;
 
       --  Call may be on a private type with unknown discriminants, in which
@@ -297,7 +297,7 @@ package body Sem_Aux is
                return True;
             end if;
 
-            Ent := Next_Entity (Ent);
+            Next_Entity (Ent);
          end loop;
 
          return False;
@@ -313,14 +313,14 @@ package body Sem_Aux is
       Ent := First_Entity (Typ);
 
       if Chars (Ent) = Name_uTag then
-         Ent := Next_Entity (Ent);
+         Next_Entity (Ent);
       end if;
 
       if Has_Completely_Hidden_Discriminant (Ent) then
          while Present (Ent) loop
             exit when Ekind (Ent) = E_Discriminant
               and then Is_Completely_Hidden (Ent);
-            Ent := Next_Entity (Ent);
+            Next_Entity (Ent);
          end loop;
       end if;
 
@@ -423,7 +423,7 @@ package body Sem_Aux is
             return Comp;
          end if;
 
-         Comp := Next_Entity (Comp);
+         Next_Entity (Comp);
       end loop;
 
       --  No tag component found
@@ -735,7 +735,7 @@ package body Sem_Aux is
             return True;
          end if;
 
-         Item := Next_Rep_Item (Item);
+         Next_Rep_Item (Item);
       end loop;
 
       return False;
@@ -984,7 +984,7 @@ package body Sem_Aux is
                      return True;
                   end if;
 
-                  C := Next_Component (C);
+                  Next_Component (C);
                end loop;
             end;
 
@@ -1216,7 +1216,7 @@ package body Sem_Aux is
                      return True;
                   end if;
 
-                  C := Next_Component (C);
+                  Next_Component (C);
                end loop;
             end;
 
@@ -1315,7 +1315,7 @@ package body Sem_Aux is
                      return True;
                   end if;
 
-                  C := Next_Component (C);
+                  Next_Component (C);
                end loop;
             end;
 
@@ -1427,7 +1427,7 @@ package body Sem_Aux is
             return Comp;
          end if;
 
-         Comp := Next_Entity (Comp);
+         Next_Entity (Comp);
       end loop;
 
       --  No tag component found
@@ -1456,7 +1456,7 @@ package body Sem_Aux is
 
       while Present (Comp) loop
          N := N + 1;
-         Comp := Next_Component_Or_Discriminant (Comp);
+         Next_Component_Or_Discriminant (Comp);
       end loop;
 
       return N;
@@ -1473,7 +1473,7 @@ package body Sem_Aux is
    begin
       while Present (Discr) loop
          N := N + 1;
-         Discr := Next_Discriminant (Discr);
+         Next_Discriminant (Discr);
       end loop;
 
       return N;
index 9eaf70b4bce0887fedc50337deb5f31f4e1d1259..13bed50cffea35ffb2bbcc9ca8872b93d40febf7 100644 (file)
@@ -1085,7 +1085,7 @@ package body Sem_Ch13 is
                end if;
             end if;
 
-            N := Next_Rep_Item (N);
+            Next_Rep_Item (N);
          end loop;
       end Inherit_Delayed_Rep_Aspects;
 
@@ -4657,7 +4657,7 @@ package body Sem_Ch13 is
 
             --  False if any subsequent formal has no default expression
 
-            Formal := Next_Formal (Formal);
+            Next_Formal (Formal);
             while Present (Formal) loop
                if No (Expression (Parent (Formal))) then
                   return False;
@@ -10203,7 +10203,7 @@ package body Sem_Ch13 is
                end if;
 
                Prev_Bit_Offset := Component_Bit_Offset (Comp);
-               Comp := Next_Component (Comp);
+               Next_Component (Comp);
             end if;
 
             Next (Clause);
@@ -13437,7 +13437,7 @@ package body Sem_Ch13 is
             end;
          end if;
 
-         ASN := Next_Rep_Item (ASN);
+         Next_Rep_Item (ASN);
       end loop;
    end Resolve_Aspect_Expressions;
 
index 1e3f0b825d27a85984230af1d314e1dfcaa19783..29e8964a7257ba40037c95f83577ba52c48af8b0 100644 (file)
@@ -2448,7 +2448,7 @@ package body Sem_Ch3 is
                end if;
 
                exit when Last_Entity (Current_Scope) = Curr;
-               Curr := Next_Entity (Curr);
+               Next_Entity (Curr);
             end loop;
          end if;
 
@@ -2683,7 +2683,7 @@ package body Sem_Ch3 is
                  and then Present (First_Entity (Current_Scope))
                then
                   while Is_Generic_Formal (Freeze_From) loop
-                     Freeze_From := Next_Entity (Freeze_From);
+                     Next_Entity (Freeze_From);
                   end loop;
 
                   Freeze_All (Freeze_From, Decl);
@@ -3811,7 +3811,7 @@ package body Sem_Ch3 is
                while Present (Comp) loop
                   Check_Component (Etype (Comp), Parent (Comp));
 
-                  Comp := Next_Component (Comp);
+                  Next_Component (Comp);
                end loop;
             end if;
          end Check_Component;
@@ -15865,7 +15865,7 @@ package body Sem_Ch3 is
                return True;
             end if;
 
-            E := Next_Entity (E);
+            Next_Entity (E);
          end loop;
 
          List := Collect_Primitive_Operations (Derived_Type);
index 787ba3ec62e7e7213a6f0076a73f49dced768327..7b8548f32ac6dc134fd7eaa94a527a3242387686 100644 (file)
@@ -6019,7 +6019,7 @@ package body Sem_Ch4 is
          return;
       end if;
 
-      Comp  := First_Entity (Prefix);
+      Comp := First_Entity (Prefix);
       while Nr_Of_Suggestions <= Max_Suggestions and then Present (Comp) loop
          if Is_Visible_Component (Comp, Sel) then
             if Is_Bad_Spelling_Of (Chars (Comp), Chars (Sel)) then
@@ -6033,7 +6033,7 @@ package body Sem_Ch4 is
             end if;
          end if;
 
-         Comp := Next_Entity (Comp);
+         Next_Entity (Comp);
       end loop;
 
       --  Report at most two suggestions
@@ -7531,7 +7531,7 @@ package body Sem_Ch4 is
                Formal := First_Entity (It.Nam);
 
                if Op = Second_Op then
-                  Formal := Next_Entity (Formal);
+                  Next_Entity (Formal);
                end if;
 
                if Is_Descendant_Of_Address (Etype (Formal)) then
index 5593001a1f770ff0c7d750fc3fcb99b208f3f521..76f696b32edde782a1ceb5134f11741ee60bfe9c 100644 (file)
@@ -2605,7 +2605,7 @@ package body Sem_Ch8 is
                   exit;
                end if;
 
-               F := Next_Formal (F);
+               Next_Formal (F);
             end loop;
 
             if Ekind (Formal_Spec) = E_Function
@@ -2643,7 +2643,7 @@ package body Sem_Ch8 is
                      end if;
                   end if;
 
-                  F := Next_Formal (F);
+                  Next_Formal (F);
                end loop;
             end if;
          end if;
@@ -5337,7 +5337,7 @@ package body Sem_Ch8 is
                      return;
                   end if;
 
-                  Lit := Next_Literal (Lit);
+                  Next_Literal (Lit);
                end if;
             end;
          end if;
@@ -8526,7 +8526,7 @@ package body Sem_Ch8 is
          while Present (Curr) loop
             Mark_Use_Type (Curr);
 
-            Curr := Next_Formal (Curr);
+            Next_Formal (Curr);
          end loop;
 
          --  Handle the return type
@@ -9407,7 +9407,7 @@ package body Sem_Ch8 is
                Set_Current_Use_Clause (Entity (N), Prev_Use_Clause (Curr));
             end if;
 
-            Curr := Next_Use_Clause (Curr);
+            Next_Use_Clause (Curr);
          end loop;
       end Update_Chain_In_Scope;
 
index 55a13009b63db0643bfe6a54d617510155086a72..57761473eda3acd0cf55343a17b508787e755b2f 100644 (file)
@@ -18794,7 +18794,7 @@ package body Sem_Elab is
             Comp := First_Component (Typ);
             while Present (Comp) loop
                Add_Task_Proc (Etype (Comp));
-               Comp := Next_Component (Comp);
+               Next_Component (Comp);
             end loop;
          end if;
 
index b209d4af0ef1753646e93bba2b1feba9d8d2b715..ce0d90740523e201c4998f0ee8ab33a095fd0746 100644 (file)
@@ -954,7 +954,7 @@ package body Sem_Eval is
                Subs := UI_To_Int (Expr_Value (First (Expressions (N))));
 
                for J in 2 .. Subs loop
-                  Indx := Next_Index (Indx);
+                  Next_Index (Indx);
                end loop;
             end if;
 
index 09d2485ad9fe159134fcc76a73e23dd9c89c42e9..0d4c21d700558abfdcaa36709bbdc2ddf42c6447 100644 (file)
@@ -20510,7 +20510,7 @@ package body Sem_Prag is
                            exit;
 
                         else
-                           Ent := Next_Literal (Ent);
+                           Next_Literal (Ent);
                         end if;
                      end loop;
                   end if;
index 61dba77457f9429993404117ba6074702164a060..2cbb35f1519b744ee49037e0e620d691b8427ed3 100644 (file)
@@ -10601,7 +10601,7 @@ package body Sem_Res is
                               while Present (Comp1)
                                 and then Chars (Comp1) /= Chars (S)
                               loop
-                                 Comp1 := Next_Entity (Comp1);
+                                 Next_Entity (Comp1);
                               end loop;
                            end if;
 
@@ -10610,7 +10610,7 @@ package body Sem_Res is
                      end if;
                   end if;
 
-                  Comp := Next_Entity (Comp);
+                  Next_Entity (Comp);
                end loop;
             end if;
 
index abce72485d15cc2a9830b4e2fecca38d62bf739e..38fa1fa2031e6cac50de1edbddd861dfde0cbc6b 100644 (file)
@@ -126,7 +126,7 @@ package body Sem_Smem is
                if Is_Access_Type (Etype (C)) then
                   return True;
                else
-                  C := Next_Discriminant (C);
+                  Next_Discriminant (C);
                end if;
             end loop;
          end if;
@@ -145,7 +145,7 @@ package body Sem_Smem is
             then
                return True;
             else
-               C := Next_Component (C);
+               Next_Component (C);
             end if;
          end loop;
 
index 174bbccc387fcbdef7303b171573a6483efdb074..b73c1f6e6236bc5c51d5d03ad0e3a47ceb5cfcd7 100644 (file)
@@ -8060,8 +8060,8 @@ package body Sem_Util is
                   return;
 
                else
-                  Actual := Next_Actual (Actual);
-                  Formal := Next_Formal (Formal);
+                  Next_Actual (Actual);
+                  Next_Formal (Formal);
                end if;
             end loop;
          end if;
@@ -12331,7 +12331,7 @@ package body Sem_Util is
                return True;
             end if;
 
-            Comp := Next_Component (Comp);
+            Next_Component (Comp);
          end loop;
       end if;
 
@@ -13033,7 +13033,7 @@ package body Sem_Util is
                   return Ent;
                end if;
 
-               Ent := Next_Entity (Ent);
+               Next_Entity (Ent);
             end loop;
          end;
       end if;
@@ -18276,7 +18276,7 @@ package body Sem_Util is
             end if;
          end if;
 
-         Idx := Next_Index (Idx);
+         Next_Index (Idx);
       end loop;
 
       return False;
@@ -25141,7 +25141,7 @@ package body Sem_Util is
             begin
                while Present (Indx) loop
                   Set_Debug_Info_Needed_If_Not_Set (Etype (Indx));
-                  Indx := Next_Index (Indx);
+                  Next_Index (Indx);
                end loop;
             end;
 
index 9da93aefa6613c60baef637ae60b9ea1c6bb6831..d472d446890cd4d0dd09667961a532d21ff88877 100644 (file)
@@ -2185,7 +2185,7 @@ package body Treepr is
                Nod := N;
                while Present (Nod) loop
                   Visit_Descendant (Union_Id (Next_Entity (Nod)));
-                  Nod := Next_Entity (Nod);
+                  Next_Entity (Nod);
                end loop;
             end;
          end if;