diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-12-09 17:16:22 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-12-09 17:16:22 +0000 |
commit | 136d479bb4214ff4edeb12e64ccb6bd6bb79a894 (patch) | |
tree | 3d8042f676028733216495b35bc6bac0d717a751 /gcc/ada/a-coorma.adb | |
parent | 2ec38781061e5b5a86351d133c1badf125b1ef21 (diff) | |
download | gcc-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-coorma.adb')
-rw-r--r-- | gcc/ada/a-coorma.adb | 125 |
1 files changed, 71 insertions, 54 deletions
diff --git a/gcc/ada/a-coorma.adb b/gcc/ada/a-coorma.adb index fad63d4e498..95b8796c8d4 100644 --- a/gcc/ada/a-coorma.adb +++ b/gcc/ada/a-coorma.adb @@ -127,17 +127,19 @@ package body Ada.Containers.Ordered_Maps is function "<" (Left, Right : Cursor) return Boolean is begin - if Left.Node = null - or else Right.Node = null - then - raise Constraint_Error; + if Left.Node = null then + raise Constraint_Error with "Left cursor of ""<"" equals No_Element"; + end if; + + if Right.Node = null then + raise Constraint_Error with "Right cursor of ""<"" equals No_Element"; end if; pragma Assert (Vet (Left.Container.Tree, Left.Node), - "bad Left cursor in ""<"""); + "Left cursor of ""<"" is bad"); pragma Assert (Vet (Right.Container.Tree, Right.Node), - "bad Right cursor in ""<"""); + "Right cursor of ""<"" is bad"); return Left.Node.Key < Right.Node.Key; end "<"; @@ -145,11 +147,11 @@ package body Ada.Containers.Ordered_Maps is function "<" (Left : Cursor; Right : Key_Type) return Boolean is begin if Left.Node = null then - raise Constraint_Error; + raise Constraint_Error with "Left cursor of ""<"" equals No_Element"; end if; pragma Assert (Vet (Left.Container.Tree, Left.Node), - "bad Left cursor in ""<"""); + "Left cursor of ""<"" is bad"); return Left.Node.Key < Right; end "<"; @@ -157,11 +159,11 @@ package body Ada.Containers.Ordered_Maps is function "<" (Left : Key_Type; Right : Cursor) return Boolean is begin if Right.Node = null then - raise Constraint_Error; + raise Constraint_Error with "Right cursor of ""<"" equals No_Element"; end if; pragma Assert (Vet (Right.Container.Tree, Right.Node), - "bad Right cursor in ""<"""); + "Right cursor of ""<"" is bad"); return Left < Right.Node.Key; end "<"; @@ -181,17 +183,19 @@ package body Ada.Containers.Ordered_Maps is function ">" (Left, Right : Cursor) return Boolean is begin - if Left.Node = null - or else Right.Node = null - then - raise Constraint_Error; + if Left.Node = null then + raise Constraint_Error with "Left cursor of "">"" equals No_Element"; + end if; + + if Right.Node = null then + raise Constraint_Error with "Right cursor of "">"" equals No_Element"; end if; pragma Assert (Vet (Left.Container.Tree, Left.Node), - "bad Left cursor in "">"""); + "Left cursor of "">"" is bad"); pragma Assert (Vet (Right.Container.Tree, Right.Node), - "bad Right cursor in "">"""); + "Right cursor of "">"" is bad"); return Right.Node.Key < Left.Node.Key; end ">"; @@ -199,11 +203,11 @@ package body Ada.Containers.Ordered_Maps is function ">" (Left : Cursor; Right : Key_Type) return Boolean is begin if Left.Node = null then - raise Constraint_Error; + raise Constraint_Error with "Left cursor of "">"" equals No_Element"; end if; pragma Assert (Vet (Left.Container.Tree, Left.Node), - "bad Left cursor in "">"""); + "Left cursor of "">"" is bad"); return Right < Left.Node.Key; end ">"; @@ -211,11 +215,11 @@ package body Ada.Containers.Ordered_Maps is function ">" (Left : Key_Type; Right : Cursor) return Boolean is begin if Right.Node = null then - raise Constraint_Error; + raise Constraint_Error with "Right cursor of "">"" equals No_Element"; end if; pragma Assert (Vet (Right.Container.Tree, Right.Node), - "bad Right cursor in "">"""); + "Right cursor of "">"" is bad"); return Right.Node.Key < Left; end ">"; @@ -302,14 +306,17 @@ package body Ada.Containers.Ordered_Maps is begin if Position.Node = null then - raise Constraint_Error; + raise Constraint_Error with + "Position cursor of Delete equals No_Element"; end if; if Position.Container /= Container'Unrestricted_Access then - raise Program_Error; + raise Program_Error with + "Position cursor of Delete designates wrong map"; end if; - pragma Assert (Vet (Tree, Position.Node), "bad cursor in Delete"); + pragma Assert (Vet (Tree, Position.Node), + "Position cursor of Delete is bad"); Tree_Operations.Delete_Node_Sans_Free (Tree, Position.Node); Free (Position.Node); @@ -322,7 +329,7 @@ package body Ada.Containers.Ordered_Maps is begin if X = null then - raise Constraint_Error; + raise Constraint_Error with "key not in map"; end if; Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X); @@ -364,11 +371,12 @@ package body Ada.Containers.Ordered_Maps is function Element (Position : Cursor) return Element_Type is begin if Position.Node = null then - raise Constraint_Error; + raise Constraint_Error with + "Position cursor of function Element equals No_Element"; end if; pragma Assert (Vet (Position.Container.Tree, Position.Node), - "bad cursor in Element"); + "Position cursor of function Element is bad"); return Position.Node.Element; end Element; @@ -378,7 +386,7 @@ package body Ada.Containers.Ordered_Maps is begin if Node = null then - raise Constraint_Error; + raise Constraint_Error with "key not in map"; end if; return Node.Element; @@ -452,7 +460,7 @@ package body Ada.Containers.Ordered_Maps is begin if T.First = null then - raise Constraint_Error; + raise Constraint_Error with "map is empty"; end if; return T.First.Element; @@ -467,7 +475,7 @@ package body Ada.Containers.Ordered_Maps is begin if T.First = null then - raise Constraint_Error; + raise Constraint_Error with "map is empty"; end if; return T.First.Key; @@ -534,7 +542,8 @@ package body Ada.Containers.Ordered_Maps is if not Inserted then if Container.Tree.Lock > 0 then - raise Program_Error; + raise Program_Error with + "attempt to tamper with cursors (map is locked)"; end if; Position.Node.Key := Key; @@ -596,7 +605,7 @@ package body Ada.Containers.Ordered_Maps is Insert (Container, Key, New_Item, Position, Inserted); if not Inserted then - raise Constraint_Error; + raise Constraint_Error with "key already in map"; end if; end Insert; @@ -746,11 +755,12 @@ package body Ada.Containers.Ordered_Maps is function Key (Position : Cursor) return Key_Type is begin if Position.Node = null then - raise Constraint_Error; + raise Constraint_Error with + "Position cursor of function Key equals No_Element"; end if; pragma Assert (Vet (Position.Container.Tree, Position.Node), - "bad cursor in Key"); + "Position cursor of function Key is bad"); return Position.Node.Key; end Key; @@ -779,7 +789,7 @@ package body Ada.Containers.Ordered_Maps is begin if T.Last = null then - raise Constraint_Error; + raise Constraint_Error with "map is empty"; end if; return T.Last.Element; @@ -794,7 +804,7 @@ package body Ada.Containers.Ordered_Maps is begin if T.Last = null then - raise Constraint_Error; + raise Constraint_Error with "map is empty"; end if; return T.Last.Key; @@ -846,7 +856,7 @@ package body Ada.Containers.Ordered_Maps is end if; pragma Assert (Vet (Position.Container.Tree, Position.Node), - "bad cursor in Next"); + "Position cursor of Next is bad"); declare Node : constant Node_Access := @@ -886,7 +896,7 @@ package body Ada.Containers.Ordered_Maps is end if; pragma Assert (Vet (Position.Container.Tree, Position.Node), - "bad cursor in Previous"); + "Position cursor of Previous is bad"); declare Node : constant Node_Access := @@ -912,11 +922,12 @@ package body Ada.Containers.Ordered_Maps is is begin if Position.Node = null then - raise Constraint_Error; + raise Constraint_Error with + "Position cursor of Query_Element equals No_Element"; end if; pragma Assert (Vet (Position.Container.Tree, Position.Node), - "bad cursor in Query_Element"); + "Position cursor of Query_Element is bad"); declare T : Tree_Type renames Position.Container.Tree; @@ -951,7 +962,7 @@ package body Ada.Containers.Ordered_Maps is ---------- procedure Read - (Stream : access Root_Stream_Type'Class; + (Stream : not null access Root_Stream_Type'Class; Container : out Map) is function Read_Node @@ -986,11 +997,11 @@ package body Ada.Containers.Ordered_Maps is end Read; procedure Read - (Stream : access Root_Stream_Type'Class; + (Stream : not null access Root_Stream_Type'Class; Item : out Cursor) is begin - raise Program_Error; + raise Program_Error with "attempt to stream map cursor"; end Read; ------------- @@ -1006,11 +1017,12 @@ package body Ada.Containers.Ordered_Maps is begin if Node = null then - raise Constraint_Error; + raise Constraint_Error with "key not in map"; end if; if Container.Tree.Lock > 0 then - raise Program_Error; + raise Program_Error with + "attempt to tamper with cursors (map is locked)"; end if; Node.Key := Key; @@ -1028,19 +1040,22 @@ package body Ada.Containers.Ordered_Maps is is begin if Position.Node = null then - raise Constraint_Error; + raise Constraint_Error with + "Position cursor of Replace_Element equals No_Element"; end if; if Position.Container /= Container'Unrestricted_Access then - raise Program_Error; + raise Program_Error with + "Position cursor of Replace_Element designates wrong map"; end if; if Container.Tree.Lock > 0 then - raise Program_Error; + raise Program_Error with + "attempt to tamper with cursors (map is locked)"; end if; pragma Assert (Vet (Container.Tree, Position.Node), - "bad cursor in Replace_Element"); + "Position cursor of Replace_Element is bad"); Position.Node.Element := New_Item; end Replace_Element; @@ -1146,15 +1161,17 @@ package body Ada.Containers.Ordered_Maps is is begin if Position.Node = null then - raise Constraint_Error; + raise Constraint_Error with + "Position cursor of Update_Element equals No_Element"; end if; if Position.Container /= Container'Unrestricted_Access then - raise Program_Error; + raise Program_Error with + "Position cursor of Update_Element designates wrong map"; end if; pragma Assert (Vet (Container.Tree, Position.Node), - "bad cursor in Update_Element"); + "Position cursor of Update_Element is bad"); declare T : Tree_Type renames Container.Tree; @@ -1189,7 +1206,7 @@ package body Ada.Containers.Ordered_Maps is ----------- procedure Write - (Stream : access Root_Stream_Type'Class; + (Stream : not null access Root_Stream_Type'Class; Container : Map) is procedure Write_Node @@ -1220,11 +1237,11 @@ package body Ada.Containers.Ordered_Maps is end Write; procedure Write - (Stream : access Root_Stream_Type'Class; + (Stream : not null access Root_Stream_Type'Class; Item : Cursor) is begin - raise Program_Error; + raise Program_Error with "attempt to stream map cursor"; end Write; end Ada.Containers.Ordered_Maps; |