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-ciorma.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-ciorma.adb')
-rw-r--r-- | gcc/ada/a-ciorma.adb | 169 |
1 files changed, 97 insertions, 72 deletions
diff --git a/gcc/ada/a-ciorma.adb b/gcc/ada/a-ciorma.adb index 256304281a8..fda5c3971de 100644 --- a/gcc/ada/a-ciorma.adb +++ b/gcc/ada/a-ciorma.adb @@ -135,23 +135,27 @@ package body Ada.Containers.Indefinite_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 Left.Node.Key = null - or else Right.Node.Key = null - then - raise Program_Error; + if Right.Node = null then + raise Constraint_Error with "Right cursor of ""<"" equals No_Element"; + end if; + + if Left.Node.Key = null then + raise Program_Error with "Left cursor in ""<"" is bad"; + end if; + + if Right.Node.Key = null then + raise Program_Error with "Right cursor in ""<"" is bad"; end if; pragma Assert (Vet (Left.Container.Tree, Left.Node), - "bad Left cursor in ""<"""); + "Left cursor in ""<"" is bad"); pragma Assert (Vet (Right.Container.Tree, Right.Node), - "bad Right cursor in ""<"""); + "Right cursor in ""<"" is bad"); return Left.Node.Key.all < Right.Node.Key.all; end "<"; @@ -159,15 +163,15 @@ package body Ada.Containers.Indefinite_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; if Left.Node.Key = null then - raise Program_Error; + raise Program_Error with "Left cursor in ""<"" is bad"; end if; pragma Assert (Vet (Left.Container.Tree, Left.Node), - "bad Left cursor in ""<"""); + "Left cursor in ""<"" is bad"); return Left.Node.Key.all < Right; end "<"; @@ -175,15 +179,15 @@ package body Ada.Containers.Indefinite_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; if Right.Node.Key = null then - raise Program_Error; + raise Program_Error with "Right cursor in ""<"" is bad"; end if; pragma Assert (Vet (Right.Container.Tree, Right.Node), - "bad Right cursor in ""<"""); + "Right cursor in ""<"" is bad"); return Left < Right.Node.Key.all; end "<"; @@ -203,23 +207,27 @@ package body Ada.Containers.Indefinite_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 Left.Node.Key = null - or else Right.Node.Key = null - then - raise Program_Error; + if Right.Node = null then + raise Constraint_Error with "Right cursor of "">"" equals No_Element"; + end if; + + if Left.Node.Key = null then + raise Program_Error with "Left cursor in ""<"" is bad"; + end if; + + if Right.Node.Key = null then + raise Program_Error with "Right cursor in ""<"" is bad"; end if; pragma Assert (Vet (Left.Container.Tree, Left.Node), - "bad Left cursor in "">"""); + "Left cursor in "">"" is bad"); pragma Assert (Vet (Right.Container.Tree, Right.Node), - "bad Right cursor in "">"""); + "Right cursor in "">"" is bad"); return Right.Node.Key.all < Left.Node.Key.all; end ">"; @@ -227,15 +235,15 @@ package body Ada.Containers.Indefinite_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; if Left.Node.Key = null then - raise Program_Error; + raise Program_Error with "Left cursor in ""<"" is bad"; end if; pragma Assert (Vet (Left.Container.Tree, Left.Node), - "bad Left cursor in "">"""); + "Left cursor in "">"" is bad"); return Right < Left.Node.Key.all; end ">"; @@ -243,15 +251,15 @@ package body Ada.Containers.Indefinite_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; if Right.Node.Key = null then - raise Program_Error; + raise Program_Error with "Right cursor in ""<"" is bad"; end if; pragma Assert (Vet (Right.Container.Tree, Right.Node), - "bad Right cursor in "">"""); + "Right cursor in "">"" is bad"); return Right.Node.Key.all < Left; end ">"; @@ -346,21 +354,23 @@ package body Ada.Containers.Indefinite_Ordered_Maps is 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.Node.Key = null or else Position.Node.Element = null then - raise Program_Error; + raise Program_Error with "Position cursor of Delete is bad"; 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 (Container.Tree, Position.Node), - "bad cursor in Delete"); + "Position cursor of Delete is bad"); Tree_Operations.Delete_Node_Sans_Free (Container.Tree, Position.Node); Free (Position.Node); @@ -373,7 +383,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is begin if X = null then - raise Constraint_Error; + raise Constraint_Error with "key not in map"; end if; Delete_Node_Sans_Free (Container.Tree, X); @@ -415,15 +425,17 @@ package body Ada.Containers.Indefinite_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; if Position.Node.Element = null then - raise Program_Error; + raise Program_Error with + "Position cursor of function Element is bad"; 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.all; end Element; @@ -433,7 +445,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is begin if Node = null then - raise Constraint_Error; + raise Constraint_Error with "key not in map"; end if; return Node.Element.all; @@ -507,7 +519,7 @@ package body Ada.Containers.Indefinite_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.all; @@ -522,7 +534,7 @@ package body Ada.Containers.Indefinite_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.all; @@ -619,7 +631,8 @@ package body Ada.Containers.Indefinite_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; K := Position.Node.Key; @@ -706,7 +719,7 @@ package body Ada.Containers.Indefinite_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; @@ -810,15 +823,17 @@ package body Ada.Containers.Indefinite_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; if Position.Node.Key = null then - raise Program_Error; + raise Program_Error with + "Position cursor of function Key is bad"; 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.all; end Key; @@ -847,7 +862,7 @@ package body Ada.Containers.Indefinite_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.all; @@ -862,7 +877,7 @@ package body Ada.Containers.Indefinite_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.all; @@ -912,7 +927,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is pragma Assert (Position.Node.Key /= null); pragma Assert (Position.Node.Element /= null); pragma Assert (Vet (Position.Container.Tree, Position.Node), - "bad cursor in Next"); + "Position cursor of Next is bad"); declare Node : constant Node_Access := @@ -955,7 +970,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is pragma Assert (Position.Node.Key /= null); pragma Assert (Position.Node.Element /= null); pragma Assert (Vet (Position.Container.Tree, Position.Node), - "bad cursor in Previous"); + "Position cursor of Previous is bad"); declare Node : constant Node_Access := @@ -986,17 +1001,19 @@ package body Ada.Containers.Indefinite_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; if Position.Node.Key = null or else Position.Node.Element = null then - raise Program_Error; + raise Program_Error with + "Position cursor of Query_Element is bad"; 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; @@ -1031,7 +1048,7 @@ package body Ada.Containers.Indefinite_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 @@ -1066,11 +1083,11 @@ package body Ada.Containers.Indefinite_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; ------------- @@ -1090,11 +1107,12 @@ package body Ada.Containers.Indefinite_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; K := Node.Key; @@ -1125,25 +1143,29 @@ package body Ada.Containers.Indefinite_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.Node.Key = null or else Position.Node.Element = null then - raise Program_Error; + raise Program_Error with + "Position cursor of Replace_Element is bad"; 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"); declare X : Element_Access := Position.Node.Element; @@ -1252,21 +1274,24 @@ package body Ada.Containers.Indefinite_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.Node.Key = null or else Position.Node.Element = null then - raise Program_Error; + raise Program_Error with + "Position cursor of Update_Element is bad"; 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 Position.Container.Tree; @@ -1301,7 +1326,7 @@ package body Ada.Containers.Indefinite_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 @@ -1332,11 +1357,11 @@ package body Ada.Containers.Indefinite_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.Indefinite_Ordered_Maps; |