diff options
Diffstat (limited to 'gcc/ada/a-cidlli.adb')
-rw-r--r-- | gcc/ada/a-cidlli.adb | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/gcc/ada/a-cidlli.adb b/gcc/ada/a-cidlli.adb index bad5a896455..183f6a8614a 100644 --- a/gcc/ada/a-cidlli.adb +++ b/gcc/ada/a-cidlli.adb @@ -242,6 +242,33 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is Free (X); end Clear; + ------------------------ + -- Constant_Reference -- + ------------------------ + + function Constant_Reference + (Container : aliased List; + Position : Cursor) return Constant_Reference_Type + is + begin + if Position.Container = null then + raise Constraint_Error with "Position cursor has no element"; + end if; + + if Position.Container /= Container'Unrestricted_Access then + raise Program_Error with + "Position cursor designates wrong container"; + end if; + + if Position.Node.Element = null then + raise Program_Error with "Node has no element"; + end if; + + pragma Assert (Vet (Position), "bad cursor in Constant_Reference"); + + return (Element => Position.Node.Element.all'Access); + end Constant_Reference; + -------------- -- Contains -- -------------- @@ -1303,27 +1330,26 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is -- Reference -- --------------- - function Constant_Reference (Container : List; Position : Cursor) - return Constant_Reference_Type is + function Reference + (Container : aliased in out List; + Position : Cursor) return Reference_Type + is begin - pragma Unreferenced (Container); - if Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; - return (Element => Position.Node.Element.all'Access); - end Constant_Reference; - - function Reference (Container : List; Position : Cursor) - return Reference_Type is - begin - pragma Unreferenced (Container); + if Position.Container /= Container'Unrestricted_Access then + raise Program_Error with + "Position cursor designates wrong container"; + end if; - if Position.Container = null then - raise Constraint_Error with "Position cursor has no element"; + if Position.Node.Element = null then + raise Program_Error with "Node has no element"; end if; + pragma Assert (Vet (Position), "bad cursor in function Reference"); + return (Element => Position.Node.Element.all'Access); end Reference; |