]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Seize opportunity to reuse List_Length
authorRonan Desplanques <desplanques@adacore.com>
Fri, 29 Sep 2023 09:25:18 +0000 (11:25 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 19 Oct 2023 14:35:21 +0000 (16:35 +0200)
This patch is intended as a readability improvement. It doesn't
change the behavior of the compiler.

gcc/ada/

* sem_ch3.adb (Constrain_Array): Replace manual list length
computation by call to List_Length.

gcc/ada/sem_ch3.adb

index c79d323395f3303eb1dd3319e740146ac80d1901..e92b46fa6f6f54c2053d7859f52e7b2f4d21f498 100644 (file)
@@ -13809,7 +13809,7 @@ package body Sem_Ch3 is
       Suffix      : Character)
    is
       C                     : constant Node_Id := Constraint (SI);
-      Number_Of_Constraints : Nat := 0;
+      Number_Of_Constraints : constant Nat := List_Length (Constraints (C));
       Index                 : Node_Id;
       S, T                  : Entity_Id;
       Constraint_OK         : Boolean := True;
@@ -13835,12 +13835,6 @@ package body Sem_Ch3 is
          Constraint_OK := False;
 
       else
-         S := First (Constraints (C));
-         while Present (S) loop
-            Number_Of_Constraints := Number_Of_Constraints + 1;
-            Next (S);
-         end loop;
-
          --  In either case, the index constraint must provide a discrete
          --  range for each index of the array type and the type of each
          --  discrete range must be the same as that of the corresponding