summaryrefslogtreecommitdiffstats
path: root/gcc/ada/a-cborse.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/a-cborse.adb')
-rw-r--r--gcc/ada/a-cborse.adb57
1 files changed, 46 insertions, 11 deletions
diff --git a/gcc/ada/a-cborse.adb b/gcc/ada/a-cborse.adb
index 62ab5f21470..17fa7950237 100644
--- a/gcc/ada/a-cborse.adb
+++ b/gcc/ada/a-cborse.adb
@@ -38,19 +38,22 @@ with Ada.Containers.Red_Black_Trees.Generic_Bounded_Set_Operations;
pragma Elaborate_All
(Ada.Containers.Red_Black_Trees.Generic_Bounded_Set_Operations);
+with Ada.Finalization; use Ada.Finalization;
with System; use type System.Address;
package body Ada.Containers.Bounded_Ordered_Sets is
- type Iterator is limited new
- Set_Iterator_Interfaces.Reversible_Iterator with record
- Container : Set_Access;
- Node : Count_Type;
- end record;
+ type Iterator is new Limited_Controlled and
+ Set_Iterator_Interfaces.Reversible_Iterator with
+ record
+ Container : Set_Access;
+ Node : Count_Type;
+ end record;
- overriding function First (Object : Iterator) return Cursor;
+ overriding procedure Finalize (Object : in out Iterator);
- overriding function Last (Object : Iterator) return Cursor;
+ overriding function First (Object : Iterator) return Cursor;
+ overriding function Last (Object : Iterator) return Cursor;
overriding function Next
(Object : Iterator;
@@ -568,6 +571,22 @@ package body Ada.Containers.Bounded_Ordered_Sets is
end if;
end Exclude;
+ --------------
+ -- Finalize --
+ --------------
+
+ procedure Finalize (Object : in out Iterator) is
+ begin
+ if Object.Container /= null then
+ declare
+ B : Natural renames Object.Container.all.Busy;
+
+ begin
+ B := B - 1;
+ end;
+ end if;
+ end Finalize;
+
----------
-- Find --
----------
@@ -1221,8 +1240,10 @@ package body Ada.Containers.Bounded_Ordered_Sets is
end Iterate;
function Iterate (Container : Set)
- return Set_Iterator_Interfaces.Reversible_Iterator'Class
+ return Set_Iterator_Interfaces.Reversible_Iterator'class
is
+ B : Natural renames Container'Unrestricted_Access.all.Busy;
+
begin
-- The value of the Node component influences the behavior of the First
-- and Last selector functions of the iterator object. When the Node
@@ -1234,12 +1255,20 @@ package body Ada.Containers.Bounded_Ordered_Sets is
-- Note: For a forward iterator, Container.First is the beginning, and
-- for a reverse iterator, Container.Last is the beginning.
- return Iterator'(Container'Unrestricted_Access, Node => 0);
+ return It : constant Iterator :=
+ Iterator'(Limited_Controlled with
+ Container => Container'Unrestricted_Access,
+ Node => 0)
+ do
+ B := B + 1;
+ end return;
end Iterate;
function Iterate (Container : Set; Start : Cursor)
- return Set_Iterator_Interfaces.Reversible_Iterator'Class
+ return Set_Iterator_Interfaces.Reversible_Iterator'class
is
+ B : Natural renames Container'Unrestricted_Access.all.Busy;
+
begin
-- It was formerly the case that when Start = No_Element, the partial
-- iterator was defined to behave the same as for a complete iterator,
@@ -1274,7 +1303,13 @@ package body Ada.Containers.Bounded_Ordered_Sets is
-- the start position has the same value irrespective of whether this
-- is a forward or reverse iteration.)
- return Iterator'(Container'Unrestricted_Access, Node => Start.Node);
+ return It : constant Iterator :=
+ Iterator'(Limited_Controlled with
+ Container => Container'Unrestricted_Access,
+ Node => Start.Node)
+ do
+ B := B + 1;
+ end return;
end Iterate;
----------
OpenPOWER on IntegriCloud