diff mbox series

[Ada] Fix iteration on formal vectors

Message ID 20220602090845.GA1010495@adacore.com
State New
Headers show
Series [Ada] Fix iteration on formal vectors | expand

Commit Message

Pierre-Marie de Rodat June 2, 2022, 9:08 a.m. UTC
We need to use Extended_Index for the Position parameter of the Element
function in formal vectors so it is compatible with other primitives of
the Iterable aspect.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnat/a-cfinve.ads (Element): Change the type of the
	Position parameter to Extended_Index.
	* libgnat/a-cfinve.adb (Element): Idem.
	* libgnat/a-cofove.ads (Element): Idem.
	* libgnat/a-cofove.adb (Element): Idem.
diff mbox series

Patch

diff --git a/gcc/ada/libgnat/a-cfinve.adb b/gcc/ada/libgnat/a-cfinve.adb
--- a/gcc/ada/libgnat/a-cfinve.adb
+++ b/gcc/ada/libgnat/a-cfinve.adb
@@ -432,7 +432,7 @@  is
 
    function Element
      (Container : Vector;
-      Index     : Index_Type) return Element_Type
+      Index     : Extended_Index) return Element_Type
    is
    begin
       if Index > Container.Last then


diff --git a/gcc/ada/libgnat/a-cfinve.ads b/gcc/ada/libgnat/a-cfinve.ads
--- a/gcc/ada/libgnat/a-cfinve.ads
+++ b/gcc/ada/libgnat/a-cfinve.ads
@@ -284,7 +284,7 @@  is
 
    function Element
      (Container : Vector;
-      Index     : Index_Type) return Element_Type
+      Index     : Extended_Index) return Element_Type
    with
      Global => null,
      Pre    => Index in First_Index (Container) .. Last_Index (Container),


diff --git a/gcc/ada/libgnat/a-cofove.adb b/gcc/ada/libgnat/a-cofove.adb
--- a/gcc/ada/libgnat/a-cofove.adb
+++ b/gcc/ada/libgnat/a-cofove.adb
@@ -370,7 +370,7 @@  is
 
    function Element
      (Container : Vector;
-      Index     : Index_Type) return Element_Type
+      Index     : Extended_Index) return Element_Type
    is
    begin
       if Index > Container.Last then


diff --git a/gcc/ada/libgnat/a-cofove.ads b/gcc/ada/libgnat/a-cofove.ads
--- a/gcc/ada/libgnat/a-cofove.ads
+++ b/gcc/ada/libgnat/a-cofove.ads
@@ -263,7 +263,7 @@  is
 
    function Element
      (Container : Vector;
-      Index     : Index_Type) return Element_Type
+      Index     : Extended_Index) return Element_Type
    with
      Global => null,
      Pre    => Index in First_Index (Container) .. Last_Index (Container),