Commit 8bfbd380 by Arnaud Charlet

[multiple changes]

2013-04-11  Arnaud Charlet  <charlet@adacore.com>

	* gnat1drv.adb: Minor code clean up.

2013-04-11  Arnaud Charlet  <charlet@adacore.com>

	* debug.adb, sem_ch13.adb (Analyze_Enumeration_Representation_Clause):
	Ignore enumeration rep clauses by default in CodePeer mode, unless
	-gnatd.I is specified.

2013-04-11  Ed Schonberg  <schonberg@adacore.com>

	* sem_util.adb (Safe_To_Capture_Value): If the node belongs to
	an expression that has been attached to the else_actions of an
	if-expression, the capture is not safe.

2013-04-11  Yannick Moy  <moy@adacore.com>

	* checks.adb (Apply_Type_Conversion_Checks): Put check mark on type
	conversion for arrays.

2013-04-11  Robert Dewar  <dewar@adacore.com>

	* a-cdlili.adb, a-cidlli.adb, a-cbdlli.adb: Minor reformatting.

2013-04-11  Johannes Kanig  <kanig@adacore.com>

	* adabkend.adb: Minor comment addition.

From-SVN: r197773
parent 256f3847
2013-04-11 Arnaud Charlet <charlet@adacore.com>
* gnat1drv.adb: Minor code clean up.
2013-04-11 Arnaud Charlet <charlet@adacore.com>
* debug.adb, sem_ch13.adb (Analyze_Enumeration_Representation_Clause):
Ignore enumeration rep clauses by default in CodePeer mode, unless
-gnatd.I is specified.
2013-04-11 Ed Schonberg <schonberg@adacore.com>
* sem_util.adb (Safe_To_Capture_Value): If the node belongs to
an expression that has been attached to the else_actions of an
if-expression, the capture is not safe.
2013-04-11 Yannick Moy <moy@adacore.com>
* checks.adb (Apply_Type_Conversion_Checks): Put check mark on type
conversion for arrays.
2013-04-11 Robert Dewar <dewar@adacore.com>
* a-cdlili.adb, a-cidlli.adb, a-cbdlli.adb: Minor reformatting.
2013-04-11 Johannes Kanig <kanig@adacore.com>
* adabkend.adb: Minor comment addition.
2013-04-11 Matthew Heaney <heaney@adacore.com> 2013-04-11 Matthew Heaney <heaney@adacore.com>
* a-cdlili.adb, a-cidlli.adb, a-cbdlli.adb ("="): Increment * a-cdlili.adb, a-cidlli.adb, a-cbdlli.adb ("="): Increment
......
...@@ -156,6 +156,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -156,6 +156,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
LR := LR - 1; LR := LR - 1;
return Result; return Result;
exception exception
when others => when others =>
BL := BL - 1; BL := BL - 1;
...@@ -359,13 +360,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -359,13 +360,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unrestricted_Access then elsif Position.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Constant_Reference"); pragma Assert (Vet (Position), "bad cursor in Constant_Reference");
declare declare
...@@ -373,6 +373,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -373,6 +373,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
return (Element => N.Element'Access); return (Element => N.Element'Access);
end; end;
end if;
end Constant_Reference; end Constant_Reference;
-------------- --------------
...@@ -397,10 +398,8 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -397,10 +398,8 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Capacity = 0 then if Capacity = 0 then
C := Source.Length; C := Source.Length;
elsif Capacity >= Source.Length then elsif Capacity >= Source.Length then
C := Capacity; C := Capacity;
else else
raise Capacity_Error with "Capacity value too small"; raise Capacity_Error with "Capacity value too small";
end if; end if;
...@@ -508,7 +507,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -508,7 +507,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
"attempt to tamper with cursors (list is busy)"; "attempt to tamper with cursors (list is busy)";
end if; end if;
for I in 1 .. Count loop for J in 1 .. Count loop
X := Container.First; X := Container.First;
pragma Assert (N (N (X).Next).Prev = Container.First); pragma Assert (N (N (X).Next).Prev = Container.First);
...@@ -547,7 +546,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -547,7 +546,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
"attempt to tamper with cursors (list is busy)"; "attempt to tamper with cursors (list is busy)";
end if; end if;
for I in 1 .. Count loop for J in 1 .. Count loop
X := Container.Last; X := Container.Last;
pragma Assert (N (N (X).Prev).Next = Container.Last); pragma Assert (N (N (X).Prev).Next = Container.Last);
...@@ -569,11 +568,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -569,11 +568,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
if Position.Node = 0 then if Position.Node = 0 then
raise Constraint_Error with raise Constraint_Error with
"Position cursor has no element"; "Position cursor has no element";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Element"); pragma Assert (Vet (Position), "bad cursor in Element");
return Position.Container.Nodes (Position.Node).Element; return Position.Container.Nodes (Position.Node).Element;
end if;
end Element; end Element;
-------------- --------------
...@@ -585,7 +585,6 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -585,7 +585,6 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
if Object.Container /= null then if Object.Container /= null then
declare declare
B : Natural renames Object.Container.all.Busy; B : Natural renames Object.Container.all.Busy;
begin begin
B := B - 1; B := B - 1;
end; end;
...@@ -648,6 +647,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -648,6 +647,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
else else
return Cursor'(Container'Unrestricted_Access, Result); return Cursor'(Container'Unrestricted_Access, Result);
end if; end if;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -664,9 +664,9 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -664,9 +664,9 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Container.First = 0 then if Container.First = 0 then
return No_Element; return No_Element;
end if; else
return Cursor'(Container'Unrestricted_Access, Container.First); return Cursor'(Container'Unrestricted_Access, Container.First);
end if;
end First; end First;
function First (Object : Iterator) return Cursor is function First (Object : Iterator) return Cursor is
...@@ -699,9 +699,9 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -699,9 +699,9 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Container.First = 0 then if Container.First = 0 then
raise Constraint_Error with "list is empty"; raise Constraint_Error with "list is empty";
end if; else
return Container.Nodes (Container.First).Element; return Container.Nodes (Container.First).Element;
end if;
end First_Element; end First_Element;
---------- ----------
...@@ -858,6 +858,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -858,6 +858,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
L := L - 1; L := L - 1;
return Result; return Result;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -962,6 +963,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -962,6 +963,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
SB := SB - 1; SB := SB - 1;
SL := SL - 1; SL := SL - 1;
exception exception
when others => when others =>
TB := TB - 1; TB := TB - 1;
...@@ -1076,6 +1078,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1076,6 +1078,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
B := B - 1; B := B - 1;
L := L - 1; L := L - 1;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -1287,7 +1290,6 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1287,7 +1290,6 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
Process (Cursor'(Container'Unrestricted_Access, Node)); Process (Cursor'(Container'Unrestricted_Access, Node));
Node := Container.Nodes (Node).Next; Node := Container.Nodes (Node).Next;
end loop; end loop;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -1380,9 +1382,9 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1380,9 +1382,9 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Container.Last = 0 then if Container.Last = 0 then
return No_Element; return No_Element;
end if; else
return Cursor'(Container'Unrestricted_Access, Container.Last); return Cursor'(Container'Unrestricted_Access, Container.Last);
end if;
end Last; end Last;
function Last (Object : Iterator) return Cursor is function Last (Object : Iterator) return Cursor is
...@@ -1415,9 +1417,9 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1415,9 +1417,9 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Container.Last = 0 then if Container.Last = 0 then
raise Constraint_Error with "list is empty"; raise Constraint_Error with "list is empty";
end if; else
return Container.Nodes (Container.Last).Element; return Container.Nodes (Container.Last).Element;
end if;
end Last_Element; end Last_Element;
------------ ------------
...@@ -1536,13 +1538,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1536,13 +1538,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
declare declare
Nodes : Node_Array renames Position.Container.Nodes; Nodes : Node_Array renames Position.Container.Nodes;
Node : constant Count_Type := Nodes (Position.Node).Next; Node : constant Count_Type := Nodes (Position.Node).Next;
begin begin
if Node = 0 then if Node = 0 then
return No_Element; return No_Element;
end if; else
return Cursor'(Position.Container, Node); return Cursor'(Position.Container, Node);
end if;
end; end;
end Next; end Next;
...@@ -1553,14 +1554,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1553,14 +1554,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
return No_Element; return No_Element;
end if; elsif Position.Container /= Object.Container then
if Position.Container /= Object.Container then
raise Program_Error with raise Program_Error with
"Position cursor of Next designates wrong list"; "Position cursor of Next designates wrong list";
end if; else
return Next (Position); return Next (Position);
end if;
end Next; end Next;
------------- -------------
...@@ -1599,9 +1598,9 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1599,9 +1598,9 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Node = 0 then if Node = 0 then
return No_Element; return No_Element;
end if; else
return Cursor'(Position.Container, Node); return Cursor'(Position.Container, Node);
end if;
end; end;
end Previous; end Previous;
...@@ -1612,14 +1611,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1612,14 +1611,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
return No_Element; return No_Element;
end if; elsif Position.Container /= Object.Container then
if Position.Container /= Object.Container then
raise Program_Error with raise Program_Error with
"Position cursor of Previous designates wrong list"; "Position cursor of Previous designates wrong list";
end if; else
return Previous (Position); return Previous (Position);
end if;
end Previous; end Previous;
------------------- -------------------
...@@ -1680,20 +1677,19 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1680,20 +1677,19 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
if N < 0 then if N < 0 then
raise Program_Error with "bad list length (corrupt stream)"; raise Program_Error with "bad list length (corrupt stream)";
end if;
if N = 0 then elsif N = 0 then
return; return;
end if;
if N > Item.Capacity then elsif N > Item.Capacity then
raise Constraint_Error with "length exceeds capacity"; raise Constraint_Error with "length exceeds capacity";
end if;
else
for Idx in 1 .. N loop for Idx in 1 .. N loop
Allocate (Item, Stream, New_Node => X); Allocate (Item, Stream, New_Node => X);
Insert_Internal (Item, Before => 0, New_Node => X); Insert_Internal (Item, Before => 0, New_Node => X);
end loop; end loop;
end if;
end Read; end Read;
procedure Read procedure Read
...@@ -1731,13 +1727,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1731,13 +1727,12 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unrestricted_Access then elsif Position.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
else
pragma Assert (Vet (Position), "bad cursor in function Reference"); pragma Assert (Vet (Position), "bad cursor in function Reference");
declare declare
...@@ -1745,6 +1740,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1745,6 +1740,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
return (Element => N.Element'Access); return (Element => N.Element'Access);
end; end;
end if;
end Reference; end Reference;
--------------------- ---------------------
...@@ -1759,21 +1755,20 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1759,21 +1755,20 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unchecked_Access then elsif Position.Container /= Container'Unchecked_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
if Container.Lock > 0 then elsif Container.Lock > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with elements (list is locked)"; "attempt to tamper with elements (list is locked)";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Replace_Element"); pragma Assert (Vet (Position), "bad cursor in Replace_Element");
Container.Nodes (Position.Node).Element := New_Item; Container.Nodes (Position.Node).Element := New_Item;
end if;
end Replace_Element; end Replace_Element;
---------------------- ----------------------
...@@ -1919,6 +1914,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1919,6 +1914,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
else else
return Cursor'(Container'Unrestricted_Access, Result); return Cursor'(Container'Unrestricted_Access, Result);
end if; end if;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -1948,7 +1944,6 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1948,7 +1944,6 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
Process (Cursor'(Container'Unrestricted_Access, Node)); Process (Cursor'(Container'Unrestricted_Access, Node));
Node := Container.Nodes (Node).Prev; Node := Container.Nodes (Node).Prev;
end loop; end loop;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -1977,31 +1972,26 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -1977,31 +1972,26 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
pragma Assert (Vet (Before), "bad cursor in Splice"); pragma Assert (Vet (Before), "bad cursor in Splice");
end if; end if;
if Target'Address = Source'Address if Target'Address = Source'Address or else Source.Length = 0 then
or else Source.Length = 0
then
return; return;
end if;
if Target.Length > Count_Type'Last - Source.Length then elsif Target.Length > Count_Type'Last - Source.Length then
raise Constraint_Error with "new length exceeds maximum"; raise Constraint_Error with "new length exceeds maximum";
end if;
if Target.Length + Source.Length > Target.Capacity then elsif Target.Length + Source.Length > Target.Capacity then
raise Capacity_Error with "new length exceeds target capacity"; raise Capacity_Error with "new length exceeds target capacity";
end if;
if Target.Busy > 0 then elsif Target.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Target (list is busy)"; "attempt to tamper with cursors of Target (list is busy)";
end if;
if Source.Busy > 0 then elsif Source.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Source (list is busy)"; "attempt to tamper with cursors of Source (list is busy)";
end if;
else
Splice_Internal (Target, Before.Node, Source); Splice_Internal (Target, Before.Node, Source);
end if;
end Splice; end Splice;
procedure Splice procedure Splice
...@@ -2583,7 +2573,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is ...@@ -2583,7 +2573,7 @@ package body Ada.Containers.Bounded_Doubly_Linked_Lists is
pragma Assert (N (Position.Node).Prev /= 0); pragma Assert (N (Position.Node).Prev /= 0);
-- ELiminate another possibility -- Eliminate another possibility
if Position.Node = L.Last then if Position.Node = L.Last then
return True; return True;
......
...@@ -135,6 +135,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -135,6 +135,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
LR := LR - 1; LR := LR - 1;
return Result; return Result;
exception exception
when others => when others =>
BL := BL - 1; BL := BL - 1;
...@@ -404,6 +405,8 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -404,6 +405,8 @@ package body Ada.Containers.Doubly_Linked_Lists is
Free (X); Free (X);
end loop; end loop;
-- The following comment is unacceptable, more detail needed ???
Position := No_Element; -- Post-York behavior Position := No_Element; -- Post-York behavior
end Delete; end Delete;
...@@ -432,7 +435,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -432,7 +435,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
"attempt to tamper with cursors (list is busy)"; "attempt to tamper with cursors (list is busy)";
end if; end if;
for I in 1 .. Count loop for J in 1 .. Count loop
X := Container.First; X := Container.First;
pragma Assert (X.Next.Prev = Container.First); pragma Assert (X.Next.Prev = Container.First);
...@@ -470,7 +473,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -470,7 +473,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
"attempt to tamper with cursors (list is busy)"; "attempt to tamper with cursors (list is busy)";
end if; end if;
for I in 1 .. Count loop for J in 1 .. Count loop
X := Container.Last; X := Container.Last;
pragma Assert (X.Prev.Next = Container.Last); pragma Assert (X.Prev.Next = Container.Last);
...@@ -492,11 +495,11 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -492,11 +495,11 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Position.Node = null then if Position.Node = null then
raise Constraint_Error with raise Constraint_Error with
"Position cursor has no element"; "Position cursor has no element";
end if; else
pragma Assert (Vet (Position), "bad cursor in Element"); pragma Assert (Vet (Position), "bad cursor in Element");
return Position.Node.Element; return Position.Node.Element;
end if;
end Element; end Element;
-------------- --------------
...@@ -549,10 +552,10 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -549,10 +552,10 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Position.Container /= Container'Unrestricted_Access then if Position.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if; else
pragma Assert (Vet (Position), "bad cursor in Find"); pragma Assert (Vet (Position), "bad cursor in Find");
end if; end if;
end if;
-- Per AI05-0022, the container implementation is required to detect -- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram. -- element tampering by a generic actual subprogram.
...@@ -572,9 +575,9 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -572,9 +575,9 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Node.Element = Item then if Node.Element = Item then
Result := Node; Result := Node;
exit; exit;
end if; else
Node := Node.Next; Node := Node.Next;
end if;
end loop; end loop;
B := B - 1; B := B - 1;
...@@ -585,6 +588,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -585,6 +588,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
else else
return Cursor'(Container'Unrestricted_Access, Result); return Cursor'(Container'Unrestricted_Access, Result);
end if; end if;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -601,9 +605,9 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -601,9 +605,9 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Container.First = null then if Container.First = null then
return No_Element; return No_Element;
end if; else
return Cursor'(Container'Unrestricted_Access, Container.First); return Cursor'(Container'Unrestricted_Access, Container.First);
end if;
end First; end First;
function First (Object : Iterator) return Cursor is function First (Object : Iterator) return Cursor is
...@@ -636,9 +640,9 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -636,9 +640,9 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Container.First = null then if Container.First = null then
raise Constraint_Error with "list is empty"; raise Constraint_Error with "list is empty";
end if; else
return Container.First.Element; return Container.First.Element;
end if;
end First_Element; end First_Element;
---------- ----------
...@@ -648,6 +652,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -648,6 +652,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
procedure Free (X : in out Node_Access) is procedure Free (X : in out Node_Access) is
procedure Deallocate is procedure Deallocate is
new Ada.Unchecked_Deallocation (Node_Type, Node_Access); new Ada.Unchecked_Deallocation (Node_Type, Node_Access);
begin begin
-- While a node is in use, as an active link in a list, its Previous and -- While a node is in use, as an active link in a list, its Previous and
-- Next components must be null, or designate a different node; this is -- Next components must be null, or designate a different node; this is
...@@ -708,6 +713,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -708,6 +713,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
L := L - 1; L := L - 1;
return Result; return Result;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -803,6 +809,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -803,6 +809,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
SB := SB - 1; SB := SB - 1;
SL := SL - 1; SL := SL - 1;
exception exception
when others => when others =>
TB := TB - 1; TB := TB - 1;
...@@ -830,9 +837,10 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -830,9 +837,10 @@ package body Ada.Containers.Doubly_Linked_Lists is
--------------- ---------------
procedure Partition (Pivot : Node_Access; Back : Node_Access) is procedure Partition (Pivot : Node_Access; Back : Node_Access) is
Node : Node_Access := Pivot.Next; Node : Node_Access;
begin begin
Node := Pivot.Next;
while Node /= Back loop while Node /= Back loop
if Node.Element < Pivot.Element then if Node.Element < Pivot.Element then
declare declare
...@@ -913,6 +921,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -913,6 +921,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
B := B - 1; B := B - 1;
L := L - 1; L := L - 1;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -954,34 +963,33 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -954,34 +963,33 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Before.Container /= Container'Unrestricted_Access then if Before.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Before cursor designates wrong list"; "Before cursor designates wrong list";
end if; else
pragma Assert (Vet (Before), "bad cursor in Insert"); pragma Assert (Vet (Before), "bad cursor in Insert");
end if; end if;
end if;
if Count = 0 then if Count = 0 then
Position := Before; Position := Before;
return; return;
end if;
if Container.Length > Count_Type'Last - Count then elsif Container.Length > Count_Type'Last - Count then
raise Constraint_Error with "new length exceeds maximum"; raise Constraint_Error with "new length exceeds maximum";
end if;
if Container.Busy > 0 then elsif Container.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors (list is busy)"; "attempt to tamper with cursors (list is busy)";
end if;
else
New_Node := new Node_Type'(New_Item, null, null); New_Node := new Node_Type'(New_Item, null, null);
Insert_Internal (Container, Before.Node, New_Node); Insert_Internal (Container, Before.Node, New_Node);
Position := Cursor'(Container'Unchecked_Access, New_Node); Position := Cursor'(Container'Unchecked_Access, New_Node);
for J in Count_Type'(2) .. Count loop for J in 2 .. Count loop
New_Node := new Node_Type'(New_Item, null, null); New_Node := new Node_Type'(New_Item, null, null);
Insert_Internal (Container, Before.Node, New_Node); Insert_Internal (Container, Before.Node, New_Node);
end loop; end loop;
end if;
end Insert; end Insert;
procedure Insert procedure Insert
...@@ -1009,10 +1017,10 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1009,10 +1017,10 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Before.Container /= Container'Unrestricted_Access then if Before.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Before cursor designates wrong list"; "Before cursor designates wrong list";
end if; else
pragma Assert (Vet (Before), "bad cursor in Insert"); pragma Assert (Vet (Before), "bad cursor in Insert");
end if; end if;
end if;
if Count = 0 then if Count = 0 then
Position := Before; Position := Before;
...@@ -1021,22 +1029,22 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1021,22 +1029,22 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Container.Length > Count_Type'Last - Count then if Container.Length > Count_Type'Last - Count then
raise Constraint_Error with "new length exceeds maximum"; raise Constraint_Error with "new length exceeds maximum";
end if;
if Container.Busy > 0 then elsif Container.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors (list is busy)"; "attempt to tamper with cursors (list is busy)";
end if;
else
New_Node := new Node_Type; New_Node := new Node_Type;
Insert_Internal (Container, Before.Node, New_Node); Insert_Internal (Container, Before.Node, New_Node);
Position := Cursor'(Container'Unchecked_Access, New_Node); Position := Cursor'(Container'Unchecked_Access, New_Node);
for J in Count_Type'(2) .. Count loop for J in 2 .. Count loop
New_Node := new Node_Type; New_Node := new Node_Type;
Insert_Internal (Container, Before.Node, New_Node); Insert_Internal (Container, Before.Node, New_Node);
end loop; end loop;
end if;
end Insert; end Insert;
--------------------- ---------------------
...@@ -1169,23 +1177,22 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1169,23 +1177,22 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Start = No_Element then if Start = No_Element then
raise Constraint_Error with raise Constraint_Error with
"Start position for iterator equals No_Element"; "Start position for iterator equals No_Element";
end if;
if Start.Container /= Container'Unrestricted_Access then elsif Start.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Start cursor of Iterate designates wrong list"; "Start cursor of Iterate designates wrong list";
end if;
else
pragma Assert (Vet (Start), "Start cursor of Iterate is bad"); pragma Assert (Vet (Start), "Start cursor of Iterate is bad");
-- The value of the Node component influences the behavior of the First -- The value of the Node component influences the behavior of the
-- and Last selector functions of the iterator object. When the Node -- First and Last selector functions of the iterator object. When
-- component is non-null (as is the case here), it means that this -- the Node component is non-null (as is the case here), it means
-- is a partial iteration, over a subset of the complete sequence of -- that this is a partial iteration, over a subset of the complete
-- items. The iterator object was constructed with a start expression, -- sequence of items. The iterator object was constructed with
-- indicating the position from which the iteration begins. Note that -- a start expression, indicating the position from which the
-- the start position has the same value irrespective of whether this -- iteration begins. Note that the start position has the same value
-- is a forward or reverse iteration. -- irrespective of whether this is a forward or reverse iteration.
return It : constant Iterator := return It : constant Iterator :=
Iterator'(Limited_Controlled with Iterator'(Limited_Controlled with
...@@ -1194,6 +1201,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1194,6 +1201,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
do do
B := B + 1; B := B + 1;
end return; end return;
end if;
end Iterate; end Iterate;
---------- ----------
...@@ -1204,9 +1212,9 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1204,9 +1212,9 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Container.Last = null then if Container.Last = null then
return No_Element; return No_Element;
end if; else
return Cursor'(Container'Unrestricted_Access, Container.Last); return Cursor'(Container'Unrestricted_Access, Container.Last);
end if;
end Last; end Last;
function Last (Object : Iterator) return Cursor is function Last (Object : Iterator) return Cursor is
...@@ -1239,9 +1247,9 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1239,9 +1247,9 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Container.Last = null then if Container.Last = null then
raise Constraint_Error with "list is empty"; raise Constraint_Error with "list is empty";
end if; else
return Container.Last.Element; return Container.Last.Element;
end if;
end Last_Element; end Last_Element;
------------ ------------
...@@ -1264,13 +1272,12 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1264,13 +1272,12 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Target'Address = Source'Address then if Target'Address = Source'Address then
return; return;
end if;
if Source.Busy > 0 then elsif Source.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Source (list is busy)"; "attempt to tamper with cursors of Source (list is busy)";
end if;
else
Clear (Target); Clear (Target);
Target.First := Source.First; Target.First := Source.First;
...@@ -1281,6 +1288,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1281,6 +1288,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
Target.Length := Source.Length; Target.Length := Source.Length;
Source.Length := 0; Source.Length := 0;
end if;
end Move; end Move;
---------- ----------
...@@ -1296,20 +1304,20 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1296,20 +1304,20 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Position.Node = null then if Position.Node = null then
return No_Element; return No_Element;
end if;
else
pragma Assert (Vet (Position), "bad cursor in Next"); pragma Assert (Vet (Position), "bad cursor in Next");
declare declare
Next_Node : constant Node_Access := Position.Node.Next; Next_Node : constant Node_Access := Position.Node.Next;
begin begin
if Next_Node = null then if Next_Node = null then
return No_Element; return No_Element;
end if; else
return Cursor'(Position.Container, Next_Node); return Cursor'(Position.Container, Next_Node);
end if;
end; end;
end if;
end Next; end Next;
function Next function Next
...@@ -1319,14 +1327,12 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1319,14 +1327,12 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
return No_Element; return No_Element;
end if; elsif Position.Container /= Object.Container then
if Position.Container /= Object.Container then
raise Program_Error with raise Program_Error with
"Position cursor of Next designates wrong list"; "Position cursor of Next designates wrong list";
end if; else
return Next (Position); return Next (Position);
end if;
end Next; end Next;
------------- -------------
...@@ -1355,20 +1361,20 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1355,20 +1361,20 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Position.Node = null then if Position.Node = null then
return No_Element; return No_Element;
end if;
else
pragma Assert (Vet (Position), "bad cursor in Previous"); pragma Assert (Vet (Position), "bad cursor in Previous");
declare declare
Prev_Node : constant Node_Access := Position.Node.Prev; Prev_Node : constant Node_Access := Position.Node.Prev;
begin begin
if Prev_Node = null then if Prev_Node = null then
return No_Element; return No_Element;
end if; else
return Cursor'(Position.Container, Prev_Node); return Cursor'(Position.Container, Prev_Node);
end if;
end; end;
end if;
end Previous; end Previous;
function Previous function Previous
...@@ -1378,14 +1384,12 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1378,14 +1384,12 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
return No_Element; return No_Element;
end if; elsif Position.Container /= Object.Container then
if Position.Container /= Object.Container then
raise Program_Error with raise Program_Error with
"Position cursor of Previous designates wrong list"; "Position cursor of Previous designates wrong list";
end if; else
return Previous (Position); return Previous (Position);
end if;
end Previous; end Previous;
------------------- -------------------
...@@ -1514,13 +1518,12 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1514,13 +1518,12 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unchecked_Access then elsif Position.Container /= Container'Unchecked_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
else
pragma Assert (Vet (Position), "bad cursor in function Reference"); pragma Assert (Vet (Position), "bad cursor in function Reference");
declare declare
...@@ -1536,6 +1539,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1536,6 +1539,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
L := L + 1; L := L + 1;
end return; end return;
end; end;
end if;
end Reference; end Reference;
--------------------- ---------------------
...@@ -1550,21 +1554,20 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1550,21 +1554,20 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unchecked_Access then elsif Position.Container /= Container'Unchecked_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
if Container.Lock > 0 then elsif Container.Lock > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with elements (list is locked)"; "attempt to tamper with elements (list is locked)";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Replace_Element"); pragma Assert (Vet (Position), "bad cursor in Replace_Element");
Position.Node.Element := New_Item; Position.Node.Element := New_Item;
end if;
end Replace_Element; end Replace_Element;
---------------------- ----------------------
...@@ -1673,10 +1676,10 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1673,10 +1676,10 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Position.Container /= Container'Unrestricted_Access then if Position.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if; else
pragma Assert (Vet (Position), "bad cursor in Reverse_Find"); pragma Assert (Vet (Position), "bad cursor in Reverse_Find");
end if; end if;
end if;
-- Per AI05-0022, the container implementation is required to detect -- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram. -- element tampering by a generic actual subprogram.
...@@ -1709,6 +1712,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1709,6 +1712,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
else else
return Cursor'(Container'Unrestricted_Access, Result); return Cursor'(Container'Unrestricted_Access, Result);
end if; end if;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -1738,7 +1742,6 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1738,7 +1742,6 @@ package body Ada.Containers.Doubly_Linked_Lists is
Process (Cursor'(Container'Unrestricted_Access, Node)); Process (Cursor'(Container'Unrestricted_Access, Node));
Node := Node.Prev; Node := Node.Prev;
end loop; end loop;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -1762,32 +1765,28 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1762,32 +1765,28 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Before.Container /= Target'Unrestricted_Access then if Before.Container /= Target'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Before cursor designates wrong container"; "Before cursor designates wrong container";
end if; else
pragma Assert (Vet (Before), "bad cursor in Splice"); pragma Assert (Vet (Before), "bad cursor in Splice");
end if; end if;
end if;
if Target'Address = Source'Address if Target'Address = Source'Address or else Source.Length = 0 then
or else Source.Length = 0
then
return; return;
end if;
if Target.Length > Count_Type'Last - Source.Length then elsif Target.Length > Count_Type'Last - Source.Length then
raise Constraint_Error with "new length exceeds maximum"; raise Constraint_Error with "new length exceeds maximum";
end if;
if Target.Busy > 0 then elsif Target.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Target (list is busy)"; "attempt to tamper with cursors of Target (list is busy)";
end if;
if Source.Busy > 0 then elsif Source.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Source (list is busy)"; "attempt to tamper with cursors of Source (list is busy)";
end if;
else
Splice_Internal (Target, Before.Node, Source); Splice_Internal (Target, Before.Node, Source);
end if;
end Splice; end Splice;
procedure Splice procedure Splice
...@@ -1800,10 +1799,10 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1800,10 +1799,10 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Before.Container /= Container'Unchecked_Access then if Before.Container /= Container'Unchecked_Access then
raise Program_Error with raise Program_Error with
"Before cursor designates wrong container"; "Before cursor designates wrong container";
end if; else
pragma Assert (Vet (Before), "bad Before cursor in Splice"); pragma Assert (Vet (Before), "bad Before cursor in Splice");
end if; end if;
end if;
if Position.Node = null then if Position.Node = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
...@@ -1908,38 +1907,37 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -1908,38 +1907,37 @@ package body Ada.Containers.Doubly_Linked_Lists is
if Before.Container /= Target'Unrestricted_Access then if Before.Container /= Target'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Before cursor designates wrong container"; "Before cursor designates wrong container";
end if; else
pragma Assert (Vet (Before), "bad Before cursor in Splice"); pragma Assert (Vet (Before), "bad Before cursor in Splice");
end if; end if;
end if;
if Position.Node = null then if Position.Node = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Source'Unrestricted_Access then elsif Position.Container /= Source'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
else
pragma Assert (Vet (Position), "bad Position cursor in Splice"); pragma Assert (Vet (Position), "bad Position cursor in Splice");
if Target.Length = Count_Type'Last then if Target.Length = Count_Type'Last then
raise Constraint_Error with "Target is full"; raise Constraint_Error with "Target is full";
end if;
if Target.Busy > 0 then elsif Target.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Target (list is busy)"; "attempt to tamper with cursors of Target (list is busy)";
end if;
if Source.Busy > 0 then elsif Source.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Source (list is busy)"; "attempt to tamper with cursors of Source (list is busy)";
end if;
else
Splice_Internal (Target, Before.Node, Source, Position.Node); Splice_Internal (Target, Before.Node, Source, Position.Node);
Position.Container := Target'Unchecked_Access; Position.Container := Target'Unchecked_Access;
end if;
end if;
end Splice; end Splice;
--------------------- ---------------------
...@@ -2210,13 +2208,12 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -2210,13 +2208,12 @@ package body Ada.Containers.Doubly_Linked_Lists is
begin begin
if Position.Node = null then if Position.Node = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unchecked_Access then elsif Position.Container /= Container'Unchecked_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Update_Element"); pragma Assert (Vet (Position), "bad cursor in Update_Element");
declare declare
...@@ -2239,6 +2236,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -2239,6 +2236,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
L := L - 1; L := L - 1;
B := B - 1; B := B - 1;
end; end;
end if;
end Update_Element; end Update_Element;
--------- ---------
...@@ -2305,8 +2303,7 @@ package body Ada.Containers.Doubly_Linked_Lists is ...@@ -2305,8 +2303,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
end if; end if;
pragma Assert pragma Assert
(Position.Node.Prev /= null (Position.Node.Prev /= null or else Position.Node = L.First);
or else Position.Node = L.First);
if Position.Node.Next = null and then Position.Node /= L.Last then if Position.Node.Next = null and then Position.Node /= L.Last then
return False; return False;
......
...@@ -138,6 +138,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -138,6 +138,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
LR := LR - 1; LR := LR - 1;
return Result; return Result;
exception exception
when others => when others =>
BL := BL - 1; BL := BL - 1;
...@@ -247,8 +248,8 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -247,8 +248,8 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Target'Address = Source'Address then if Target'Address = Source'Address then
return; return;
end if;
else
Target.Clear; Target.Clear;
Node := Source.First; Node := Source.First;
...@@ -256,6 +257,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -256,6 +257,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
Target.Append (Node.Element.all); Target.Append (Node.Element.all);
Node := Node.Next; Node := Node.Next;
end loop; end loop;
end if;
end Assign; end Assign;
----------- -----------
...@@ -316,17 +318,14 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -316,17 +318,14 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unrestricted_Access then elsif Position.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if; elsif Position.Node.Element = null then
if Position.Node.Element = null then
raise Program_Error with "Node has no element"; raise Program_Error with "Node has no element";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Constant_Reference"); pragma Assert (Vet (Position), "bad cursor in Constant_Reference");
declare declare
...@@ -342,6 +341,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -342,6 +341,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
L := L + 1; L := L + 1;
end return; end return;
end; end;
end if;
end Constant_Reference; end Constant_Reference;
-------------- --------------
...@@ -434,6 +434,8 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -434,6 +434,8 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
Free (X); Free (X);
end loop; end loop;
-- Fix this junk comment ???
Position := No_Element; -- Post-York behavior Position := No_Element; -- Post-York behavior
end Delete; end Delete;
...@@ -451,18 +453,16 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -451,18 +453,16 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
if Count >= Container.Length then if Count >= Container.Length then
Clear (Container); Clear (Container);
return; return;
end if;
if Count = 0 then elsif Count = 0 then
return; return;
end if;
if Container.Busy > 0 then elsif Container.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors (list is busy)"; "attempt to tamper with cursors (list is busy)";
end if;
for I in 1 .. Count loop else
for J in 1 .. Count loop
X := Container.First; X := Container.First;
pragma Assert (X.Next.Prev = Container.First); pragma Assert (X.Next.Prev = Container.First);
...@@ -473,6 +473,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -473,6 +473,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
Free (X); Free (X);
end loop; end loop;
end if;
end Delete_First; end Delete_First;
----------------- -----------------
...@@ -489,18 +490,16 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -489,18 +490,16 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
if Count >= Container.Length then if Count >= Container.Length then
Clear (Container); Clear (Container);
return; return;
end if;
if Count = 0 then elsif Count = 0 then
return; return;
end if;
if Container.Busy > 0 then elsif Container.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors (list is busy)"; "attempt to tamper with cursors (list is busy)";
end if;
for I in 1 .. Count loop else
for J in 1 .. Count loop
X := Container.Last; X := Container.Last;
pragma Assert (X.Prev.Next = Container.Last); pragma Assert (X.Prev.Next = Container.Last);
...@@ -511,6 +510,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -511,6 +510,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
Free (X); Free (X);
end loop; end loop;
end if;
end Delete_Last; end Delete_Last;
------------- -------------
...@@ -522,16 +522,16 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -522,16 +522,16 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
if Position.Node = null then if Position.Node = null then
raise Constraint_Error with raise Constraint_Error with
"Position cursor has no element"; "Position cursor has no element";
end if;
if Position.Node.Element = null then elsif Position.Node.Element = null then
raise Program_Error with raise Program_Error with
"Position cursor has no element"; "Position cursor has no element";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Element"); pragma Assert (Vet (Position), "bad cursor in Element");
return Position.Node.Element.all; return Position.Node.Element.all;
end if;
end Element; end Element;
-------------- --------------
...@@ -583,15 +583,15 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -583,15 +583,15 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
else else
if Node.Element = null then if Node.Element = null then
raise Program_Error; raise Program_Error;
end if;
if Position.Container /= Container'Unrestricted_Access then elsif Position.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Find"); pragma Assert (Vet (Position), "bad cursor in Find");
end if; end if;
end if;
-- Per AI05-0022, the container implementation is required to detect -- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram. -- element tampering by a generic actual subprogram.
...@@ -624,6 +624,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -624,6 +624,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
else else
return Cursor'(Container'Unrestricted_Access, Result); return Cursor'(Container'Unrestricted_Access, Result);
end if; end if;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -640,9 +641,9 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -640,9 +641,9 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Container.First = null then if Container.First = null then
return No_Element; return No_Element;
end if; else
return Cursor'(Container'Unrestricted_Access, Container.First); return Cursor'(Container'Unrestricted_Access, Container.First);
end if;
end First; end First;
function First (Object : Iterator) return Cursor is function First (Object : Iterator) return Cursor is
...@@ -675,9 +676,9 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -675,9 +676,9 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Container.First = null then if Container.First = null then
raise Constraint_Error with "list is empty"; raise Constraint_Error with "list is empty";
end if; else
return Container.First.Element.all; return Container.First.Element.all;
end if;
end First_Element; end First_Element;
---------- ----------
...@@ -747,7 +748,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -747,7 +748,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
Node := Container.First; Node := Container.First;
Result := True; Result := True;
for I in 2 .. Container.Length loop for J in 2 .. Container.Length loop
if Node.Next.Element.all < Node.Element.all then if Node.Next.Element.all < Node.Element.all then
Result := False; Result := False;
exit; exit;
...@@ -760,6 +761,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -760,6 +761,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
L := L - 1; L := L - 1;
return Result; return Result;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -786,23 +788,19 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -786,23 +788,19 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
if Source.Is_Empty then if Source.Is_Empty then
return; return;
end if;
if Target'Address = Source'Address then elsif Target'Address = Source'Address then
raise Program_Error with raise Program_Error with
"Target and Source denote same non-empty container"; "Target and Source denote same non-empty container";
end if;
if Target.Length > Count_Type'Last - Source.Length then elsif Target.Length > Count_Type'Last - Source.Length then
raise Constraint_Error with "new length exceeds maximum"; raise Constraint_Error with "new length exceeds maximum";
end if;
if Target.Busy > 0 then elsif Target.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Target (list is busy)"; "attempt to tamper with cursors of Target (list is busy)";
end if;
if Source.Busy > 0 then elsif Source.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Source (list is busy)"; "attempt to tamper with cursors of Source (list is busy)";
end if; end if;
...@@ -854,6 +852,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -854,6 +852,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
SB := SB - 1; SB := SB - 1;
SL := SL - 1; SL := SL - 1;
exception exception
when others => when others =>
TB := TB - 1; TB := TB - 1;
...@@ -872,22 +871,26 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -872,22 +871,26 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
procedure Sort (Container : in out List) is procedure Sort (Container : in out List) is
procedure Partition (Pivot : Node_Access; Back : Node_Access); procedure Partition (Pivot : Node_Access; Back : Node_Access);
-- Comment ???
procedure Sort (Front, Back : Node_Access); procedure Sort (Front, Back : Node_Access);
-- Comment??? Confusing name??? change name???
--------------- ---------------
-- Partition -- -- Partition --
--------------- ---------------
procedure Partition (Pivot : Node_Access; Back : Node_Access) is procedure Partition (Pivot : Node_Access; Back : Node_Access) is
Node : Node_Access := Pivot.Next; Node : Node_Access;
begin begin
Node := Pivot.Next;
while Node /= Back loop while Node /= Back loop
if Node.Element.all < Pivot.Element.all then if Node.Element.all < Pivot.Element.all then
declare declare
Prev : constant Node_Access := Node.Prev; Prev : constant Node_Access := Node.Prev;
Next : constant Node_Access := Node.Next; Next : constant Node_Access := Node.Next;
begin begin
Prev.Next := Next; Prev.Next := Next;
...@@ -1003,17 +1006,15 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1003,17 +1006,15 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
if Before.Container /= Container'Unrestricted_Access then if Before.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors (list is busy)"; "attempt to tamper with cursors (list is busy)";
end if;
if Before.Node = null elsif Before.Node = null or else Before.Node.Element = null then
or else Before.Node.Element = null
then
raise Program_Error with raise Program_Error with
"Before cursor has no element"; "Before cursor has no element";
end if;
else
pragma Assert (Vet (Before), "bad cursor in Insert"); pragma Assert (Vet (Before), "bad cursor in Insert");
end if; end if;
end if;
if Count = 0 then if Count = 0 then
Position := Before; Position := Before;
...@@ -1052,8 +1053,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1052,8 +1053,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
Insert_Internal (Container, Before.Node, New_Node); Insert_Internal (Container, Before.Node, New_Node);
Position := Cursor'(Container'Unchecked_Access, New_Node); Position := Cursor'(Container'Unchecked_Access, New_Node);
for J in Count_Type'(2) .. Count loop for J in 2 .. Count loop
declare declare
Element : Element_Access := new Element_Type'(New_Item); Element : Element_Access := new Element_Type'(New_Item);
begin begin
...@@ -1213,23 +1213,22 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1213,23 +1213,22 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
if Start = No_Element then if Start = No_Element then
raise Constraint_Error with raise Constraint_Error with
"Start position for iterator equals No_Element"; "Start position for iterator equals No_Element";
end if;
if Start.Container /= Container'Unrestricted_Access then elsif Start.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Start cursor of Iterate designates wrong list"; "Start cursor of Iterate designates wrong list";
end if;
else
pragma Assert (Vet (Start), "Start cursor of Iterate is bad"); pragma Assert (Vet (Start), "Start cursor of Iterate is bad");
-- The value of the Node component influences the behavior of the First -- The value of the Node component influences the behavior of the
-- and Last selector functions of the iterator object. When the Node -- First and Last selector functions of the iterator object. When
-- component is non-null (as is the case here), it means that this -- the Node component is non-null (as is the case here), it means
-- is a partial iteration, over a subset of the complete sequence of -- that this is a partial iteration, over a subset of the complete
-- items. The iterator object was constructed with a start expression, -- sequence of items. The iterator object was constructed with
-- indicating the position from which the iteration begins. Note that -- a start expression, indicating the position from which the
-- the start position has the same value irrespective of whether this -- iteration begins. Note that the start position has the same value
-- is a forward or reverse iteration. -- irrespective of whether this is a forward or reverse iteration.
return It : constant Iterator := return It : constant Iterator :=
Iterator'(Limited_Controlled with Iterator'(Limited_Controlled with
...@@ -1238,6 +1237,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1238,6 +1237,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
do do
B := B + 1; B := B + 1;
end return; end return;
end if;
end Iterate; end Iterate;
---------- ----------
...@@ -1248,9 +1248,9 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1248,9 +1248,9 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Container.Last = null then if Container.Last = null then
return No_Element; return No_Element;
end if; else
return Cursor'(Container'Unrestricted_Access, Container.Last); return Cursor'(Container'Unrestricted_Access, Container.Last);
end if;
end Last; end Last;
function Last (Object : Iterator) return Cursor is function Last (Object : Iterator) return Cursor is
...@@ -1283,9 +1283,9 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1283,9 +1283,9 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Container.Last = null then if Container.Last = null then
raise Constraint_Error with "list is empty"; raise Constraint_Error with "list is empty";
end if; else
return Container.Last.Element.all; return Container.Last.Element.all;
end if;
end Last_Element; end Last_Element;
------------ ------------
...@@ -1305,13 +1305,12 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1305,13 +1305,12 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Target'Address = Source'Address then if Target'Address = Source'Address then
return; return;
end if;
if Source.Busy > 0 then elsif Source.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Source (list is busy)"; "attempt to tamper with cursors of Source (list is busy)";
end if;
else
Clear (Target); Clear (Target);
Target.First := Source.First; Target.First := Source.First;
...@@ -1322,6 +1321,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1322,6 +1321,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
Target.Length := Source.Length; Target.Length := Source.Length;
Source.Length := 0; Source.Length := 0;
end if;
end Move; end Move;
---------- ----------
...@@ -1337,8 +1337,8 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1337,8 +1337,8 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Position.Node = null then if Position.Node = null then
return No_Element; return No_Element;
end if;
else
pragma Assert (Vet (Position), "bad cursor in Next"); pragma Assert (Vet (Position), "bad cursor in Next");
declare declare
...@@ -1346,24 +1346,23 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1346,24 +1346,23 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Next_Node = null then if Next_Node = null then
return No_Element; return No_Element;
end if; else
return Cursor'(Position.Container, Next_Node); return Cursor'(Position.Container, Next_Node);
end if;
end; end;
end if;
end Next; end Next;
function Next (Object : Iterator; Position : Cursor) return Cursor is function Next (Object : Iterator; Position : Cursor) return Cursor is
begin begin
if Position.Container = null then if Position.Container = null then
return No_Element; return No_Element;
end if; elsif Position.Container /= Object.Container then
if Position.Container /= Object.Container then
raise Program_Error with raise Program_Error with
"Position cursor of Next designates wrong list"; "Position cursor of Next designates wrong list";
end if; else
return Next (Position); return Next (Position);
end if;
end Next; end Next;
------------- -------------
...@@ -1392,8 +1391,8 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1392,8 +1391,8 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Position.Node = null then if Position.Node = null then
return No_Element; return No_Element;
end if;
else
pragma Assert (Vet (Position), "bad cursor in Previous"); pragma Assert (Vet (Position), "bad cursor in Previous");
declare declare
...@@ -1401,24 +1400,23 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1401,24 +1400,23 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Prev_Node = null then if Prev_Node = null then
return No_Element; return No_Element;
end if; else
return Cursor'(Position.Container, Prev_Node); return Cursor'(Position.Container, Prev_Node);
end if;
end; end;
end if;
end Previous; end Previous;
function Previous (Object : Iterator; Position : Cursor) return Cursor is function Previous (Object : Iterator; Position : Cursor) return Cursor is
begin begin
if Position.Container = null then if Position.Container = null then
return No_Element; return No_Element;
end if; elsif Position.Container /= Object.Container then
if Position.Container /= Object.Container then
raise Program_Error with raise Program_Error with
"Position cursor of Previous designates wrong list"; "Position cursor of Previous designates wrong list";
end if; else
return Previous (Position); return Previous (Position);
end if;
end Previous; end Previous;
------------------- -------------------
...@@ -1433,13 +1431,12 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1433,13 +1431,12 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
if Position.Node = null then if Position.Node = null then
raise Constraint_Error with raise Constraint_Error with
"Position cursor has no element"; "Position cursor has no element";
end if;
if Position.Node.Element = null then elsif Position.Node.Element = null then
raise Program_Error with raise Program_Error with
"Position cursor has no element"; "Position cursor has no element";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Query_Element"); pragma Assert (Vet (Position), "bad cursor in Query_Element");
declare declare
...@@ -1463,6 +1460,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1463,6 +1460,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
L := L - 1; L := L - 1;
B := B - 1; B := B - 1;
end; end;
end if;
end Query_Element; end Query_Element;
---------- ----------
...@@ -1553,17 +1551,15 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1553,17 +1551,15 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unrestricted_Access then elsif Position.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
if Position.Node.Element = null then elsif Position.Node.Element = null then
raise Program_Error with "Node has no element"; raise Program_Error with "Node has no element";
end if;
else
pragma Assert (Vet (Position), "bad cursor in function Reference"); pragma Assert (Vet (Position), "bad cursor in function Reference");
declare declare
...@@ -1579,6 +1575,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1579,6 +1575,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
L := L + 1; L := L + 1;
end return; end return;
end; end;
end if;
end Reference; end Reference;
--------------------- ---------------------
...@@ -1593,29 +1590,26 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1593,29 +1590,26 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
begin begin
if Position.Container = null then if Position.Container = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unchecked_Access then elsif Position.Container /= Container'Unchecked_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
if Container.Lock > 0 then elsif Container.Lock > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with elements (list is locked)"; "attempt to tamper with elements (list is locked)";
end if;
if Position.Node.Element = null then elsif Position.Node.Element = null then
raise Program_Error with raise Program_Error with
"Position cursor has no element"; "Position cursor has no element";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Replace_Element"); pragma Assert (Vet (Position), "bad cursor in Replace_Element");
declare declare
-- The element allocator may need an accessibility check in the case -- The element allocator may need an accessibility check in the
-- the actual type is class-wide or has access discriminants (see -- case the actual type is class-wide or has access discriminants
-- RM 4.8(10.1) and AI12-0035). -- (see RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check); pragma Unsuppress (Accessibility_Check);
...@@ -1625,6 +1619,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1625,6 +1619,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
Position.Node.Element := new Element_Type'(New_Item); Position.Node.Element := new Element_Type'(New_Item);
Free (X); Free (X);
end; end;
end if;
end Replace_Element; end Replace_Element;
---------------------- ----------------------
...@@ -1732,15 +1727,15 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1732,15 +1727,15 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
else else
if Node.Element = null then if Node.Element = null then
raise Program_Error with "Position cursor has no element"; raise Program_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unrestricted_Access then elsif Position.Container /= Container'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Position cursor designates wrong container"; "Position cursor designates wrong container";
end if;
else
pragma Assert (Vet (Position), "bad cursor in Reverse_Find"); pragma Assert (Vet (Position), "bad cursor in Reverse_Find");
end if; end if;
end if;
-- Per AI05-0022, the container implementation is required to detect -- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram. -- element tampering by a generic actual subprogram.
...@@ -1773,6 +1768,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1773,6 +1768,7 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
else else
return Cursor'(Container'Unrestricted_Access, Result); return Cursor'(Container'Unrestricted_Access, Result);
end if; end if;
exception exception
when others => when others =>
B := B - 1; B := B - 1;
...@@ -1825,39 +1821,33 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1825,39 +1821,33 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
if Before.Container /= Target'Unrestricted_Access then if Before.Container /= Target'Unrestricted_Access then
raise Program_Error with raise Program_Error with
"Before cursor designates wrong container"; "Before cursor designates wrong container";
end if;
if Before.Node = null elsif Before.Node = null or else Before.Node.Element = null then
or else Before.Node.Element = null
then
raise Program_Error with raise Program_Error with
"Before cursor has no element"; "Before cursor has no element";
end if;
else
pragma Assert (Vet (Before), "bad cursor in Splice"); pragma Assert (Vet (Before), "bad cursor in Splice");
end if; end if;
end if;
if Target'Address = Source'Address if Target'Address = Source'Address or else Source.Length = 0 then
or else Source.Length = 0
then
return; return;
end if;
if Target.Length > Count_Type'Last - Source.Length then elsif Target.Length > Count_Type'Last - Source.Length then
raise Constraint_Error with "new length exceeds maximum"; raise Constraint_Error with "new length exceeds maximum";
end if;
if Target.Busy > 0 then elsif Target.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Target (list is busy)"; "attempt to tamper with cursors of Target (list is busy)";
end if;
if Source.Busy > 0 then elsif Source.Busy > 0 then
raise Program_Error with raise Program_Error with
"attempt to tamper with cursors of Source (list is busy)"; "attempt to tamper with cursors of Source (list is busy)";
end if;
else
Splice_Internal (Target, Before.Node, Source); Splice_Internal (Target, Before.Node, Source);
end if;
end Splice; end Splice;
procedure Splice procedure Splice
...@@ -1870,17 +1860,15 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is ...@@ -1870,17 +1860,15 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
if Before.Container /= Container'Unchecked_Access then if Before.Container /= Container'Unchecked_Access then
raise Program_Error with raise Program_Error with
"Before cursor designates wrong container"; "Before cursor designates wrong container";
end if;
if Before.Node = null elsif Before.Node = null or else Before.Node.Element = null then
or else Before.Node.Element = null
then
raise Program_Error with raise Program_Error with
"Before cursor has no element"; "Before cursor has no element";
end if;
else
pragma Assert (Vet (Before), "bad Before cursor in Splice"); pragma Assert (Vet (Before), "bad Before cursor in Splice");
end if; end if;
end if;
if Position.Node = null then if Position.Node = null then
raise Constraint_Error with "Position cursor has no element"; raise Constraint_Error with "Position cursor has no element";
......
...@@ -234,8 +234,15 @@ package body Adabkend is ...@@ -234,8 +234,15 @@ package body Adabkend is
then then
if Is_Switch (Argv) then if Is_Switch (Argv) then
Fail ("Object file name missing after -gnatO"); Fail ("Object file name missing after -gnatO");
-- In Alfa_Mode, such an object file is never written, and the
-- call to Set_Output_Object_File_Name may fail (e.g. when the
-- object file name does not have the expected suffix). So we
-- skip that call when Alfa_Mode is set.
elsif Alfa_Mode then elsif Alfa_Mode then
Output_File_Name_Seen := True; Output_File_Name_Seen := True;
else else
Set_Output_Object_File_Name (Argv); Set_Output_Object_File_Name (Argv);
Output_File_Name_Seen := True; Output_File_Name_Seen := True;
......
...@@ -3244,13 +3244,18 @@ package body Checks is ...@@ -3244,13 +3244,18 @@ package body Checks is
Reason => CE_Discriminant_Check_Failed)); Reason => CE_Discriminant_Check_Failed));
end; end;
-- For arrays, conversions are applied during expansion, to take into -- For arrays, checks are set now, but conversions are applied during
-- accounts changes of representation. The checks become range checks on -- expansion, to take into accounts changes of representation. The
-- the base type or length checks on the subtype, depending on whether -- checks become range checks on the base type or length checks on the
-- the target type is unconstrained or constrained. -- subtype, depending on whether the target type is unconstrained or
-- constrained.
elsif Is_Array_Type (Target_Type) then
if Is_Constrained (Target_Type) then
Set_Do_Length_Check (N);
else else
null; Set_Do_Range_Check (Expr);
end if;
end if; end if;
end Apply_Type_Conversion_Checks; end Apply_Type_Conversion_Checks;
......
...@@ -126,7 +126,7 @@ package body Debug is ...@@ -126,7 +126,7 @@ package body Debug is
-- d.F Alfa mode -- d.F Alfa mode
-- d.G Frame condition mode for gnat2why -- d.G Frame condition mode for gnat2why
-- d.H Standard package only mode for gnat2why -- d.H Standard package only mode for gnat2why
-- d.I -- d.I Do not ignore enum representation clauses in CodePeer mode
-- d.J Disable parallel SCIL generation mode -- d.J Disable parallel SCIL generation mode
-- d.K Alfa detection only mode for gnat2why -- d.K Alfa detection only mode for gnat2why
-- d.L Depend on back end for limited types in if and case expressions -- d.L Depend on back end for limited types in if and case expressions
...@@ -614,6 +614,12 @@ package body Debug is ...@@ -614,6 +614,12 @@ package body Debug is
-- will only generate Why code for package Standard. Any given input -- will only generate Why code for package Standard. Any given input
-- file will be ignored. -- file will be ignored.
-- d.I Do not ignore enum representation clauses in CodePeer mode.
-- The default of ignoring representation clauses for enumeration
-- types in CodePeer is good for the majority of Ada code, but in some
-- cases being able to change this default might be useful to remove
-- some false positives.
-- d.J Disable parallel SCIL generation. Normally SCIL file generation is -- d.J Disable parallel SCIL generation. Normally SCIL file generation is
-- done in parallel to speed processing. This switch disables this -- done in parallel to speed processing. This switch disables this
-- behavior. -- behavior.
......
...@@ -293,11 +293,15 @@ procedure Gnat1drv is ...@@ -293,11 +293,15 @@ procedure Gnat1drv is
Formal_Extensions := True; Formal_Extensions := True;
end if; end if;
-- Alfa_Mode is activated by default in the gnat2why executable, but -- Enable Alfa_Mode when using -gnatd.F switch
-- can also be activated using the -gnatd.F switch.
if Debug_Flag_Dot_FF or else Alfa_Mode then if Debug_Flag_Dot_FF then
Alfa_Mode := True; Alfa_Mode := True;
end if;
-- Alfa_Mode is also activated by default in the gnat2why executable
if Alfa_Mode then
-- Set strict standard interpretation of compiler permissions -- Set strict standard interpretation of compiler permissions
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
with Aspects; use Aspects; with Aspects; use Aspects;
with Atree; use Atree; with Atree; use Atree;
with Checks; use Checks; with Checks; use Checks;
with Debug; use Debug;
with Einfo; use Einfo; with Einfo; use Einfo;
with Elists; use Elists; with Elists; use Elists;
with Errout; use Errout; with Errout; use Errout;
...@@ -4253,6 +4254,14 @@ package body Sem_Ch13 is ...@@ -4253,6 +4254,14 @@ package body Sem_Ch13 is
return; return;
end if; end if;
-- Ignore enumeration rep clauses by default in CodePeer mode,
-- unless -gnatd.I is specified, as a work around for potential false
-- positive messages.
if CodePeer_Mode and not Debug_Flag_Dot_II then
return;
end if;
-- First some basic error checks -- First some basic error checks
Find_Type (Ident); Find_Type (Ident);
......
...@@ -12984,6 +12984,19 @@ package body Sem_Util is ...@@ -12984,6 +12984,19 @@ package body Sem_Util is
else else
Desc := P; Desc := P;
P := Parent (P); P := Parent (P);
-- A special Ada 2012 case: the original node may be part
-- of the else_actions of a conditional expression, in which
-- case it might not have been expanded yet, and appears in
-- a non-syntactic list of actions. In that case it is clearly
-- not safe to save a value.
if No (P)
and then Is_List_Member (Desc)
and then No (Parent (List_Containing (Desc)))
then
return False;
end if;
end if; end if;
end loop; end loop;
end; end;
......
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