[Ada] Add N_Has_Bounds and N_Is_Index
authorRichard Kenner <kenner@adacore.com>
Sat, 31 Jul 2021 15:02:47 +0000 (11:02 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 23 Sep 2021 13:06:16 +0000 (13:06 +0000)
gcc/ada/

* einfo-utils.adb (Next_Index): Verify input and output are
N_Is_Index.
* gen_il-gen-gen_nodes.adb (N_Has_Bounds, N_Is_Index): Add.
* gen_il-types.ads (N_Has_Bounds, N_Is_Index): Likewise.
* sem_ch3.adb (Array_Type_Declaration): Use Next, not
Next_Index.
* sem_ch12.adb (Formal_Dimensions): Likewise.
* sem_util.adb (Is_Valid_Renaming): Likewise.

gcc/ada/einfo-utils.adb
gcc/ada/gen_il-gen-gen_nodes.adb
gcc/ada/gen_il-types.ads
gcc/ada/sem_ch12.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_util.adb

index 23e93c9..c6c3277 100644 (file)
@@ -1976,6 +1976,8 @@ package body Einfo.Utils is
 
    function Next_Index (Id : Node_Id) return Node_Id is
    begin
+      pragma Assert (Nkind (Id) in N_Is_Index);
+      pragma Assert (No (Next (Id)) or else Nkind (Next (Id)) in N_Is_Index);
       return Next (Id);
    end Next_Index;
 
index 55ba71d..43d77f2 100644 (file)
@@ -1649,4 +1649,17 @@ begin -- Gen_IL.Gen.Gen_Nodes
              N_Terminate_Alternative));
    --  Nodes with condition fields (does not include N_Raise_xxx_Error)
 
+   Union (N_Has_Bounds,
+          Children =>
+            (N_Range,
+             N_Real_Range_Specification,
+             N_Signed_Integer_Type_Definition));
+   --  Nodes that have Low_Bound and High_Bound defined
+
+   Union (N_Is_Index,
+          Children =>
+            (N_Has_Bounds,
+             N_Has_Entity,
+             N_Subtype_Indication));
+   --  Nodes that can be an index of an array
 end Gen_IL.Gen.Gen_Nodes;
index 321eec6..3df185d 100644 (file)
@@ -88,9 +88,12 @@ package Gen_IL.Types is
       N_Generic_Declaration,
       N_Generic_Instantiation,
       N_Generic_Renaming_Declaration,
+      N_Has_Bounds,
       N_Has_Chars,
+      N_Has_Condition,
       N_Has_Entity,
       N_Has_Etype,
+      N_Is_Index,
       N_Multiplying_Operator,
       N_Later_Decl_Item,
       N_Membership_Test,
@@ -111,7 +114,6 @@ package Gen_IL.Types is
       N_Statement_Other_Than_Procedure_Call,
       N_Subprogram_Call,
       N_Subprogram_Instantiation,
-      N_Has_Condition,
       N_Subexpr,
       N_Subprogram_Specification,
       N_Unary_Op,
index eca2abf..e4cb7e3 100644 (file)
@@ -13047,7 +13047,7 @@ package body Sem_Ch12 is
 
             while Present (Index) loop
                Num := Num + 1;
-               Next_Index (Index);
+               Next (Index);
             end loop;
 
             return Num;
index 677a9f5..bf81f76 100644 (file)
@@ -6254,7 +6254,7 @@ package body Sem_Ch3 is
 
          --  Move to next index
 
-         Next_Index (Index);
+         Next (Index);
          Nb_Index := Nb_Index + 1;
       end loop;
 
index f5cf834..de18f75 100644 (file)
@@ -7445,7 +7445,7 @@ package body Sem_Util is
                      return False;
                   end if;
 
-                  Next_Index (Indx);
+                  Next (Indx);
                end loop;
             end;