Commit 7cdc672b by Matthew Heaney Committed by Arnaud Charlet

a-convec.adb (Merge): Added assertions to check whether vector params are sorted.

2005-12-05  Matthew Heaney  <heaney@adacore.com>

	* a-convec.adb (Merge): Added assertions to check whether vector params
	are sorted.

	* a-coinve.adb (Merge): Added assertions to check whether vector params
	are sorted.

	* a-cohama.ads (Cursor'Write): raises Program_Error per latest AI-302
	draft.
	(Cursor'Read): raises PE

	* a-cohama.adb (Insert.New_Node): Uses box-style syntax to init elem
	to its default value.

	* a-cihama.adb: Manually check whether cursor's key and elem are
	non-null

	* a-cidlli.ads, a-cidlli.adb (Splice): Changed param name and param mode
	(Merge): Assert that target and source lists are in order
	(Swap): Declare non-const temporaries, to pass to Splice

	* a-cdlili.ads: (Splice): Changed param name and param mode

	* a-cdlili.adb: (Splice): Changed param name and param mode
	(Merge): Assert that target and source lists are in order
	(Swap): Declare non-const temporaries, to pass to Splice

	* a-ciorma.ads, a-coorma.ads: (Read): declare Stream param as not null
	(Write): declare Stream param as not null

	* a-ciorma.adb, a-coorma.adb: All explicit raise statements now include
	an exception message.

From-SVN: r108287
parent 9582a3cd
...@@ -466,11 +466,19 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -466,11 +466,19 @@ package body Ada.Containers.Doubly_Linked_Lists is
end if; end if;
while RI.Node /= null loop while RI.Node /= null loop
pragma Assert (RI.Node.Next = null
or else not (RI.Node.Next.Element <
RI.Node.Element));
if LI.Node = null then if LI.Node = null then
Splice (Target, No_Element, Source); Splice (Target, No_Element, Source);
return; return;
end if; end if;
pragma Assert (LI.Node.Next = null
or else not (LI.Node.Next.Element <
LI.Node.Element));
if RI.Node.Element < LI.Node.Element then if RI.Node.Element < LI.Node.Element then
declare declare
RJ : Cursor := RI; RJ : Cursor := RI;
...@@ -1289,13 +1297,13 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1289,13 +1297,13 @@ package body Ada.Containers.Doubly_Linked_Lists is
end Splice; end Splice;
procedure Splice procedure Splice
(Target : in out List; (Container : in out List;
Before : Cursor; Before : Cursor;
Position : Cursor) Position : in out Cursor)
is is
begin begin
if Before.Container /= null then if Before.Container /= null then
if Before.Container /= Target'Unchecked_Access then if Before.Container /= Container'Unchecked_Access then
raise Program_Error; raise Program_Error;
end if; end if;
...@@ -1306,7 +1314,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1306,7 +1314,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
raise Constraint_Error; raise Constraint_Error;
end if; end if;
if Position.Container /= Target'Unrestricted_Access then if Position.Container /= Container'Unrestricted_Access then
raise Program_Error; raise Program_Error;
end if; end if;
...@@ -1318,59 +1326,59 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1318,59 +1326,59 @@ package body Ada.Containers.Doubly_Linked_Lists is
return; return;
end if; end if;
pragma Assert (Target.Length >= 2); pragma Assert (Container.Length >= 2);
if Target.Busy > 0 then if Container.Busy > 0 then
raise Program_Error; raise Program_Error;
end if; end if;
if Before.Node = null then if Before.Node = null then
pragma Assert (Position.Node /= Target.Last); pragma Assert (Position.Node /= Container.Last);
if Position.Node = Target.First then if Position.Node = Container.First then
Target.First := Position.Node.Next; Container.First := Position.Node.Next;
Target.First.Prev := null; Container.First.Prev := null;
else else
Position.Node.Prev.Next := Position.Node.Next; Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev; Position.Node.Next.Prev := Position.Node.Prev;
end if; end if;
Target.Last.Next := Position.Node; Container.Last.Next := Position.Node;
Position.Node.Prev := Target.Last; Position.Node.Prev := Container.Last;
Target.Last := Position.Node; Container.Last := Position.Node;
Target.Last.Next := null; Container.Last.Next := null;
return; return;
end if; end if;
if Before.Node = Target.First then if Before.Node = Container.First then
pragma Assert (Position.Node /= Target.First); pragma Assert (Position.Node /= Container.First);
if Position.Node = Target.Last then if Position.Node = Container.Last then
Target.Last := Position.Node.Prev; Container.Last := Position.Node.Prev;
Target.Last.Next := null; Container.Last.Next := null;
else else
Position.Node.Prev.Next := Position.Node.Next; Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev; Position.Node.Next.Prev := Position.Node.Prev;
end if; end if;
Target.First.Prev := Position.Node; Container.First.Prev := Position.Node;
Position.Node.Next := Target.First; Position.Node.Next := Container.First;
Target.First := Position.Node; Container.First := Position.Node;
Target.First.Prev := null; Container.First.Prev := null;
return; return;
end if; end if;
if Position.Node = Target.First then if Position.Node = Container.First then
Target.First := Position.Node.Next; Container.First := Position.Node.Next;
Target.First.Prev := null; Container.First.Prev := null;
elsif Position.Node = Target.Last then elsif Position.Node = Container.Last then
Target.Last := Position.Node.Prev; Container.Last := Position.Node.Prev;
Target.Last.Next := null; Container.Last.Next := null;
else else
Position.Node.Prev.Next := Position.Node.Next; Position.Node.Prev.Next := Position.Node.Next;
...@@ -1383,8 +1391,8 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1383,8 +1391,8 @@ package body Ada.Containers.Doubly_Linked_Lists is
Before.Node.Prev := Position.Node; Before.Node.Prev := Position.Node;
Position.Node.Next := Before.Node; Position.Node.Next := Before.Node;
pragma Assert (Target.First.Prev = null); pragma Assert (Container.First.Prev = null);
pragma Assert (Target.Last.Next = null); pragma Assert (Container.Last.Next = null);
end Splice; end Splice;
procedure Splice procedure Splice
...@@ -1570,24 +1578,26 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1570,24 +1578,26 @@ package body Ada.Containers.Doubly_Linked_Lists is
declare declare
I_Next : constant Cursor := Next (I); I_Next : constant Cursor := Next (I);
J_Copy : Cursor := J;
begin begin
if I_Next = J then if I_Next = J then
Splice (Container, Before => I, Position => J); Splice (Container, Before => I, Position => J_Copy);
else else
declare declare
J_Next : constant Cursor := Next (J); J_Next : constant Cursor := Next (J);
I_Copy : Cursor := I;
begin begin
if J_Next = I then if J_Next = I then
Splice (Container, Before => J, Position => I); Splice (Container, Before => J, Position => I_Copy);
else else
pragma Assert (Container.Length >= 3); pragma Assert (Container.Length >= 3);
Splice (Container, Before => I_Next, Position => J); Splice (Container, Before => I_Next, Position => J_Copy);
Splice (Container, Before => J_Next, Position => I); Splice (Container, Before => J_Next, Position => I_Copy);
end if; end if;
end; end;
end if; end if;
......
...@@ -145,9 +145,9 @@ package Ada.Containers.Doubly_Linked_Lists is ...@@ -145,9 +145,9 @@ package Ada.Containers.Doubly_Linked_Lists is
Position : in out Cursor); Position : in out Cursor);
procedure Splice procedure Splice
(Target : in out List; (Container : in out List;
Before : Cursor; Before : Cursor;
Position : Cursor); Position : in out Cursor);
function First (Container : List) return Cursor; function First (Container : List) return Cursor;
......
...@@ -514,11 +514,19 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -514,11 +514,19 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
LI := First (Target); LI := First (Target);
RI := First (Source); RI := First (Source);
while RI.Node /= null loop while RI.Node /= null loop
pragma Assert (RI.Node.Next = null
or else not (RI.Node.Next.Element.all <
RI.Node.Element.all));
if LI.Node = null then if LI.Node = null then
Splice (Target, No_Element, Source); Splice (Target, No_Element, Source);
return; return;
end if; end if;
pragma Assert (LI.Node.Next = null
or else not (LI.Node.Next.Element.all <
LI.Node.Element.all));
if RI.Node.Element.all < LI.Node.Element.all then if RI.Node.Element.all < LI.Node.Element.all then
declare declare
RJ : Cursor := RI; RJ : Cursor := RI;
...@@ -1333,13 +1341,13 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1333,13 +1341,13 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
end Splice; end Splice;
procedure Splice procedure Splice
(Target : in out List; (Container : in out List;
Before : Cursor; Before : Cursor;
Position : Cursor) Position : in out Cursor)
is is
begin begin
if Before.Container /= null then if Before.Container /= null then
if Before.Container /= Target'Unchecked_Access then if Before.Container /= Container'Unchecked_Access then
raise Program_Error; raise Program_Error;
end if; end if;
...@@ -1360,7 +1368,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1360,7 +1368,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
raise Program_Error; raise Program_Error;
end if; end if;
if Position.Container /= Target'Unrestricted_Access then if Position.Container /= Container'Unrestricted_Access then
raise Program_Error; raise Program_Error;
end if; end if;
...@@ -1372,59 +1380,59 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1372,59 +1380,59 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
return; return;
end if; end if;
pragma Assert (Target.Length >= 2); pragma Assert (Container.Length >= 2);
if Target.Busy > 0 then if Container.Busy > 0 then
raise Program_Error; raise Program_Error;
end if; end if;
if Before.Node = null then if Before.Node = null then
pragma Assert (Position.Node /= Target.Last); pragma Assert (Position.Node /= Container.Last);
if Position.Node = Target.First then if Position.Node = Container.First then
Target.First := Position.Node.Next; Container.First := Position.Node.Next;
Target.First.Prev := null; Container.First.Prev := null;
else else
Position.Node.Prev.Next := Position.Node.Next; Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev; Position.Node.Next.Prev := Position.Node.Prev;
end if; end if;
Target.Last.Next := Position.Node; Container.Last.Next := Position.Node;
Position.Node.Prev := Target.Last; Position.Node.Prev := Container.Last;
Target.Last := Position.Node; Container.Last := Position.Node;
Target.Last.Next := null; Container.Last.Next := null;
return; return;
end if; end if;
if Before.Node = Target.First then if Before.Node = Container.First then
pragma Assert (Position.Node /= Target.First); pragma Assert (Position.Node /= Container.First);
if Position.Node = Target.Last then if Position.Node = Container.Last then
Target.Last := Position.Node.Prev; Container.Last := Position.Node.Prev;
Target.Last.Next := null; Container.Last.Next := null;
else else
Position.Node.Prev.Next := Position.Node.Next; Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev; Position.Node.Next.Prev := Position.Node.Prev;
end if; end if;
Target.First.Prev := Position.Node; Container.First.Prev := Position.Node;
Position.Node.Next := Target.First; Position.Node.Next := Container.First;
Target.First := Position.Node; Container.First := Position.Node;
Target.First.Prev := null; Container.First.Prev := null;
return; return;
end if; end if;
if Position.Node = Target.First then if Position.Node = Container.First then
Target.First := Position.Node.Next; Container.First := Position.Node.Next;
Target.First.Prev := null; Container.First.Prev := null;
elsif Position.Node = Target.Last then elsif Position.Node = Container.Last then
Target.Last := Position.Node.Prev; Container.Last := Position.Node.Prev;
Target.Last.Next := null; Container.Last.Next := null;
else else
Position.Node.Prev.Next := Position.Node.Next; Position.Node.Prev.Next := Position.Node.Next;
...@@ -1437,8 +1445,8 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1437,8 +1445,8 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
Before.Node.Prev := Position.Node; Before.Node.Prev := Position.Node;
Position.Node.Next := Before.Node; Position.Node.Next := Before.Node;
pragma Assert (Target.First.Prev = null); pragma Assert (Container.First.Prev = null);
pragma Assert (Target.Last.Next = null); pragma Assert (Container.Last.Next = null);
end Splice; end Splice;
procedure Splice procedure Splice
...@@ -1631,23 +1639,26 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1631,23 +1639,26 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
declare declare
I_Next : constant Cursor := Next (I); I_Next : constant Cursor := Next (I);
J_Copy : Cursor := J;
begin begin
if I_Next = J then if I_Next = J then
Splice (Container, Before => I, Position => J); Splice (Container, Before => I, Position => J_Copy);
else else
declare declare
J_Next : constant Cursor := Next (J); J_Next : constant Cursor := Next (J);
I_Copy : Cursor := I;
begin begin
if J_Next = I then if J_Next = I then
Splice (Container, Before => J, Position => I); Splice (Container, Before => J, Position => I_Copy);
else else
pragma Assert (Container.Length >= 3); pragma Assert (Container.Length >= 3);
Splice (Container, Before => I_Next, Position => J); Splice (Container, Before => I_Next, Position => J_Copy);
Splice (Container, Before => J_Next, Position => I); Splice (Container, Before => J_Next, Position => I_Copy);
end if; end if;
end; end;
end if; end if;
......
...@@ -136,9 +136,9 @@ package Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -136,9 +136,9 @@ package Ada.Containers.Indefinite_Doubly_Linked_Lists is
Position : in out Cursor); Position : in out Cursor);
procedure Splice procedure Splice
(Target : in out List; (Container : in out List;
Before : Cursor; Before : Cursor;
Position : Cursor); Position : in out Cursor);
function First (Container : List) return Cursor; function First (Container : List) return Cursor;
......
...@@ -237,6 +237,10 @@ package body Ada.Containers.Indefinite_Hashed_Maps is ...@@ -237,6 +237,10 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
raise Constraint_Error; raise Constraint_Error;
end if; end if;
if Position.Node.Element = null then
raise Program_Error;
end if;
return Position.Node.Element.all; return Position.Node.Element.all;
end Element; end Element;
...@@ -267,6 +271,12 @@ package body Ada.Containers.Indefinite_Hashed_Maps is ...@@ -267,6 +271,12 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
raise Constraint_Error; raise Constraint_Error;
end if; end if;
if Left.Node.Key = null
or else Right.Node.Key = null
then
raise Program_Error;
end if;
return Equivalent_Keys (Left.Node.Key.all, Right.Node.Key.all); return Equivalent_Keys (Left.Node.Key.all, Right.Node.Key.all);
end Equivalent_Keys; end Equivalent_Keys;
...@@ -281,6 +291,10 @@ package body Ada.Containers.Indefinite_Hashed_Maps is ...@@ -281,6 +291,10 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
raise Constraint_Error; raise Constraint_Error;
end if; end if;
if Left.Node.Key = null then
raise Program_Error;
end if;
return Equivalent_Keys (Left.Node.Key.all, Right); return Equivalent_Keys (Left.Node.Key.all, Right);
end Equivalent_Keys; end Equivalent_Keys;
...@@ -295,6 +309,10 @@ package body Ada.Containers.Indefinite_Hashed_Maps is ...@@ -295,6 +309,10 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
raise Constraint_Error; raise Constraint_Error;
end if; end if;
if Right.Node.Key = null then
raise Program_Error;
end if;
return Equivalent_Keys (Left, Right.Node.Key.all); return Equivalent_Keys (Left, Right.Node.Key.all);
end Equivalent_Keys; end Equivalent_Keys;
...@@ -595,6 +613,10 @@ package body Ada.Containers.Indefinite_Hashed_Maps is ...@@ -595,6 +613,10 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
raise Constraint_Error; raise Constraint_Error;
end if; end if;
if Position.Node.Key = null then
raise Program_Error;
end if;
return Position.Node.Key.all; return Position.Node.Key.all;
end Key; end Key;
...@@ -641,6 +663,12 @@ package body Ada.Containers.Indefinite_Hashed_Maps is ...@@ -641,6 +663,12 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
return No_Element; return No_Element;
end if; end if;
if Position.Node.Key = null
or else Position.Node.Element = null
then
raise Program_Error;
end if;
declare declare
HT : Hash_Table_Type renames Position.Container.HT; HT : Hash_Table_Type renames Position.Container.HT;
Node : constant Node_Access := HT_Ops.Next (HT, Position.Node); Node : constant Node_Access := HT_Ops.Next (HT, Position.Node);
...@@ -670,6 +698,12 @@ package body Ada.Containers.Indefinite_Hashed_Maps is ...@@ -670,6 +698,12 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
raise Constraint_Error; raise Constraint_Error;
end if; end if;
if Position.Node.Key = null
or else Position.Node.Element = null
then
raise Program_Error;
end if;
declare declare
M : Map renames Position.Container.all; M : Map renames Position.Container.all;
HT : Hash_Table_Type renames M.HT'Unrestricted_Access.all; HT : Hash_Table_Type renames M.HT'Unrestricted_Access.all;
...@@ -807,6 +841,12 @@ package body Ada.Containers.Indefinite_Hashed_Maps is ...@@ -807,6 +841,12 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
raise Constraint_Error; raise Constraint_Error;
end if; end if;
if Position.Node.Key = null
or else Position.Node.Element = null
then
raise Program_Error;
end if;
if Position.Container /= Container'Unrestricted_Access then if Position.Container /= Container'Unrestricted_Access then
raise Program_Error; raise Program_Error;
end if; end if;
...@@ -862,6 +902,12 @@ package body Ada.Containers.Indefinite_Hashed_Maps is ...@@ -862,6 +902,12 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
raise Constraint_Error; raise Constraint_Error;
end if; end if;
if Position.Node.Key = null
or else Position.Node.Element = null
then
raise Program_Error;
end if;
if Position.Container /= Container'Unrestricted_Access then if Position.Container /= Container'Unrestricted_Access then
raise Program_Error; raise Program_Error;
end if; end if;
......
...@@ -215,13 +215,13 @@ private ...@@ -215,13 +215,13 @@ private
end record; end record;
procedure Write procedure Write
(Stream : access Root_Stream_Type'Class; (Stream : not null access Root_Stream_Type'Class;
Item : Cursor); Item : Cursor);
for Cursor'Write use Write; for Cursor'Write use Write;
procedure Read procedure Read
(Stream : access Root_Stream_Type'Class; (Stream : not null access Root_Stream_Type'Class;
Item : out Cursor); Item : out Cursor);
for Cursor'Read use Read; for Cursor'Read use Read;
...@@ -229,13 +229,13 @@ private ...@@ -229,13 +229,13 @@ private
No_Element : constant Cursor := Cursor'(null, null); No_Element : constant Cursor := Cursor'(null, null);
procedure Write procedure Write
(Stream : access Root_Stream_Type'Class; (Stream : not null access Root_Stream_Type'Class;
Container : Map); Container : Map);
for Map'Write use Write; for Map'Write use Write;
procedure Read procedure Read
(Stream : access Root_Stream_Type'Class; (Stream : not null access Root_Stream_Type'Class;
Container : out Map); Container : out Map);
for Map'Read use Read; for Map'Read use Read;
......
...@@ -438,18 +438,10 @@ package body Ada.Containers.Hashed_Maps is ...@@ -438,18 +438,10 @@ package body Ada.Containers.Hashed_Maps is
-------------- --------------
function New_Node (Next : Node_Access) return Node_Access is function New_Node (Next : Node_Access) return Node_Access is
Node : Node_Access := new Node_Type; -- Ada 2005 aggregate possible?
begin begin
Node.Key := Key; return new Node_Type'(Key => Key,
Node.Next := Next; Element => <>,
Next => Next);
return Node;
exception
when others =>
Free (Node);
raise;
end New_Node; end New_Node;
HT : Hash_Table_Type renames Container.HT; HT : Hash_Table_Type renames Container.HT;
...@@ -490,9 +482,8 @@ package body Ada.Containers.Hashed_Maps is ...@@ -490,9 +482,8 @@ package body Ada.Containers.Hashed_Maps is
-------------- --------------
function New_Node (Next : Node_Access) return Node_Access is function New_Node (Next : Node_Access) return Node_Access is
Node : constant Node_Access := new Node_Type'(Key, New_Item, Next);
begin begin
return Node; return new Node_Type'(Key, New_Item, Next);
end New_Node; end New_Node;
HT : Hash_Table_Type renames Container.HT; HT : Hash_Table_Type renames Container.HT;
......
...@@ -212,18 +212,18 @@ private ...@@ -212,18 +212,18 @@ private
Node : Node_Access; Node : Node_Access;
end record; end record;
procedure Write
(Stream : access Root_Stream_Type'Class;
Item : Cursor);
for Cursor'Write use Write;
procedure Read procedure Read
(Stream : access Root_Stream_Type'Class; (Stream : access Root_Stream_Type'Class;
Item : out Cursor); Item : out Cursor);
for Cursor'Read use Read; for Cursor'Read use Read;
procedure Write
(Stream : access Root_Stream_Type'Class;
Item : Cursor);
for Cursor'Write use Write;
No_Element : constant Cursor := (Container => null, Node => null); No_Element : constant Cursor := (Container => null, Node => null);
end Ada.Containers.Hashed_Maps; end Ada.Containers.Hashed_Maps;
...@@ -895,6 +895,12 @@ package body Ada.Containers.Indefinite_Vectors is ...@@ -895,6 +895,12 @@ package body Ada.Containers.Indefinite_Vectors is
J := Target.Last; J := Target.Last;
while Source.Last >= Index_Type'First loop while Source.Last >= Index_Type'First loop
pragma Assert
(Source.Last <= Index_Type'First
or else not (Is_Less
(Source.Elements (Source.Last),
Source.Elements (Source.Last - 1))));
if I < Index_Type'First then if I < Index_Type'First then
declare declare
Src : Elements_Type renames Src : Elements_Type renames
...@@ -909,6 +915,12 @@ package body Ada.Containers.Indefinite_Vectors is ...@@ -909,6 +915,12 @@ package body Ada.Containers.Indefinite_Vectors is
return; return;
end if; end if;
pragma Assert
(I <= Index_Type'First
or else not (Is_Less
(Target.Elements (I),
Target.Elements (I - 1))));
declare declare
Src : Element_Access renames Source.Elements (Source.Last); Src : Element_Access renames Source.Elements (Source.Last);
Tgt : Element_Access renames Target.Elements (I); Tgt : Element_Access renames Target.Elements (I);
......
...@@ -660,6 +660,10 @@ package body Ada.Containers.Vectors is ...@@ -660,6 +660,10 @@ package body Ada.Containers.Vectors is
J := Target.Last; J := Target.Last;
while Source.Last >= Index_Type'First loop while Source.Last >= Index_Type'First loop
pragma Assert (Source.Last <= Index_Type'First
or else not (Source.Elements (Source.Last) <
Source.Elements (Source.Last - 1)));
if I < Index_Type'First then if I < Index_Type'First then
Target.Elements (Index_Type'First .. J) := Target.Elements (Index_Type'First .. J) :=
Source.Elements (Index_Type'First .. Source.Last); Source.Elements (Index_Type'First .. Source.Last);
...@@ -668,6 +672,10 @@ package body Ada.Containers.Vectors is ...@@ -668,6 +672,10 @@ package body Ada.Containers.Vectors is
return; return;
end if; end if;
pragma Assert (I <= Index_Type'First
or else not (Target.Elements (I) <
Target.Elements (I - 1)));
if Source.Elements (Source.Last) < Target.Elements (I) then if Source.Elements (Source.Last) < Target.Elements (I) then
Target.Elements (J) := Target.Elements (I); Target.Elements (J) := Target.Elements (I);
I := I - 1; I := I - 1;
...@@ -1923,7 +1931,6 @@ package body Ada.Containers.Vectors is ...@@ -1923,7 +1931,6 @@ package body Ada.Containers.Vectors is
B : Natural renames V.Busy; B : Natural renames V.Busy;
begin begin
B := B + 1; B := B + 1;
begin begin
...@@ -1937,7 +1944,6 @@ package body Ada.Containers.Vectors is ...@@ -1937,7 +1944,6 @@ package body Ada.Containers.Vectors is
end; end;
B := B - 1; B := B - 1;
end Reverse_Iterate; end Reverse_Iterate;
---------------- ----------------
......
...@@ -217,13 +217,13 @@ private ...@@ -217,13 +217,13 @@ private
end record; end record;
procedure Write procedure Write
(Stream : access Root_Stream_Type'Class; (Stream : not null access Root_Stream_Type'Class;
Item : Cursor); Item : Cursor);
for Cursor'Write use Write; for Cursor'Write use Write;
procedure Read procedure Read
(Stream : access Root_Stream_Type'Class; (Stream : not null access Root_Stream_Type'Class;
Item : out Cursor); Item : out Cursor);
for Cursor'Read use Read; for Cursor'Read use Read;
...@@ -231,13 +231,13 @@ private ...@@ -231,13 +231,13 @@ private
No_Element : constant Cursor := Cursor'(null, null); No_Element : constant Cursor := Cursor'(null, null);
procedure Write procedure Write
(Stream : access Root_Stream_Type'Class; (Stream : not null access Root_Stream_Type'Class;
Container : Map); Container : Map);
for Map'Write use Write; for Map'Write use Write;
procedure Read procedure Read
(Stream : access Root_Stream_Type'Class; (Stream : not null access Root_Stream_Type'Class;
Container : out Map); Container : out Map);
for Map'Read use Read; for Map'Read use Read;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment