summaryrefslogtreecommitdiff
path: root/gcc/ada/a-cdlili.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-09 17:16:22 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-09 17:16:22 +0000
commit136d479bb4214ff4edeb12e64ccb6bd6bb79a894 (patch)
tree3d8042f676028733216495b35bc6bac0d717a751 /gcc/ada/a-cdlili.adb
parent2ec38781061e5b5a86351d133c1badf125b1ef21 (diff)
downloadgcc-136d479bb4214ff4edeb12e64ccb6bd6bb79a894.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108287 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-cdlili.adb')
-rw-r--r--gcc/ada/a-cdlili.adb82
1 files changed, 46 insertions, 36 deletions
diff --git a/gcc/ada/a-cdlili.adb b/gcc/ada/a-cdlili.adb
index 958a105a734..c6d7dbff0fe 100644
--- a/gcc/ada/a-cdlili.adb
+++ b/gcc/ada/a-cdlili.adb
@@ -466,11 +466,19 @@ package body Ada.Containers.Doubly_Linked_Lists is
end if;
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
Splice (Target, No_Element, Source);
return;
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
declare
RJ : Cursor := RI;
@@ -1289,13 +1297,13 @@ package body Ada.Containers.Doubly_Linked_Lists is
end Splice;
procedure Splice
- (Target : in out List;
- Before : Cursor;
- Position : Cursor)
+ (Container : in out List;
+ Before : Cursor;
+ Position : in out Cursor)
is
begin
if Before.Container /= null then
- if Before.Container /= Target'Unchecked_Access then
+ if Before.Container /= Container'Unchecked_Access then
raise Program_Error;
end if;
@@ -1306,7 +1314,7 @@ package body Ada.Containers.Doubly_Linked_Lists is
raise Constraint_Error;
end if;
- if Position.Container /= Target'Unrestricted_Access then
+ if Position.Container /= Container'Unrestricted_Access then
raise Program_Error;
end if;
@@ -1318,59 +1326,59 @@ package body Ada.Containers.Doubly_Linked_Lists is
return;
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;
end if;
if Before.Node = null then
- pragma Assert (Position.Node /= Target.Last);
+ pragma Assert (Position.Node /= Container.Last);
- if Position.Node = Target.First then
- Target.First := Position.Node.Next;
- Target.First.Prev := null;
+ if Position.Node = Container.First then
+ Container.First := Position.Node.Next;
+ Container.First.Prev := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev;
end if;
- Target.Last.Next := Position.Node;
- Position.Node.Prev := Target.Last;
+ Container.Last.Next := Position.Node;
+ Position.Node.Prev := Container.Last;
- Target.Last := Position.Node;
- Target.Last.Next := null;
+ Container.Last := Position.Node;
+ Container.Last.Next := null;
return;
end if;
- if Before.Node = Target.First then
- pragma Assert (Position.Node /= Target.First);
+ if Before.Node = Container.First then
+ pragma Assert (Position.Node /= Container.First);
- if Position.Node = Target.Last then
- Target.Last := Position.Node.Prev;
- Target.Last.Next := null;
+ if Position.Node = Container.Last then
+ Container.Last := Position.Node.Prev;
+ Container.Last.Next := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev;
end if;
- Target.First.Prev := Position.Node;
- Position.Node.Next := Target.First;
+ Container.First.Prev := Position.Node;
+ Position.Node.Next := Container.First;
- Target.First := Position.Node;
- Target.First.Prev := null;
+ Container.First := Position.Node;
+ Container.First.Prev := null;
return;
end if;
- if Position.Node = Target.First then
- Target.First := Position.Node.Next;
- Target.First.Prev := null;
+ if Position.Node = Container.First then
+ Container.First := Position.Node.Next;
+ Container.First.Prev := null;
- elsif Position.Node = Target.Last then
- Target.Last := Position.Node.Prev;
- Target.Last.Next := null;
+ elsif Position.Node = Container.Last then
+ Container.Last := Position.Node.Prev;
+ Container.Last.Next := null;
else
Position.Node.Prev.Next := Position.Node.Next;
@@ -1383,8 +1391,8 @@ package body Ada.Containers.Doubly_Linked_Lists is
Before.Node.Prev := Position.Node;
Position.Node.Next := Before.Node;
- pragma Assert (Target.First.Prev = null);
- pragma Assert (Target.Last.Next = null);
+ pragma Assert (Container.First.Prev = null);
+ pragma Assert (Container.Last.Next = null);
end Splice;
procedure Splice
@@ -1570,24 +1578,26 @@ package body Ada.Containers.Doubly_Linked_Lists is
declare
I_Next : constant Cursor := Next (I);
+ J_Copy : Cursor := J;
begin
if I_Next = J then
- Splice (Container, Before => I, Position => J);
+ Splice (Container, Before => I, Position => J_Copy);
else
declare
J_Next : constant Cursor := Next (J);
+ I_Copy : Cursor := I;
begin
if J_Next = I then
- Splice (Container, Before => J, Position => I);
+ Splice (Container, Before => J, Position => I_Copy);
else
pragma Assert (Container.Length >= 3);
- Splice (Container, Before => I_Next, Position => J);
- Splice (Container, Before => J_Next, Position => I);
+ Splice (Container, Before => I_Next, Position => J_Copy);
+ Splice (Container, Before => J_Next, Position => I_Copy);
end if;
end;
end if;