diff options
Diffstat (limited to 'gcc/ada/a-cdlili.adb')
-rw-r--r-- | gcc/ada/a-cdlili.adb | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/gcc/ada/a-cdlili.adb b/gcc/ada/a-cdlili.adb index f56578c0364..55defaec254 100644 --- a/gcc/ada/a-cdlili.adb +++ b/gcc/ada/a-cdlili.adb @@ -219,6 +219,29 @@ package body Ada.Containers.Doubly_Linked_Lists is pragma Warnings (On); 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; + + pragma Assert (Vet (Position), "bad cursor in Constant_Reference"); + + return (Element => Position.Node.Element'Access); + end Constant_Reference; + -------------- -- Contains -- -------------- @@ -1277,31 +1300,22 @@ package body Ada.Containers.Doubly_Linked_Lists is -- Reference -- --------------- - function Constant_Reference - (Container : List; - Position : Cursor) return Constant_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'Access); - end Constant_Reference; - function Reference - (Container : List; + (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; + if Position.Container /= Container'Unchecked_Access then + raise Program_Error with + "Position cursor designates wrong container"; + end if; + + pragma Assert (Vet (Position), "bad cursor in function Reference"); + return (Element => Position.Node.Element'Access); end Reference; |