]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[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 23e93c989d02d4b157cc3ed38332f9ef6f13300f..c6c3277b346935247c240909ff3cbd55f72a16fe 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 55ba71d7efb13e2a20a5ed927d39675926795eeb..43d77f2032f509b06f687a92334fad5938aed0b5 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 321eec6504c635394f5f2fc90a407237fc731bf0..3df185de2b37a5c04416ec2cebe05387a1cea012 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 eca2abf3d939eea3816a5ce56debb0a32c5e9626..e4cb7e3229c39135419be975dea459558a00198d 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 677a9f5951359778de478b34d444f737fe72fa0a..bf81f763faaed8474b75482f7a2be126c073d356 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 f5cf8342c1a10c5ffe1789f72e3aa03e4eb62087..de18f75f0215bff6c9a794a95042a21ed7a027b1 100644 (file)
@@ -7445,7 +7445,7 @@ package body Sem_Util is
                      return False;
                   end if;
 
-                  Next_Index (Indx);
+                  Next (Indx);
                end loop;
             end;