aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/a-convec.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2012-01-10 12:06:44 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2012-01-10 12:06:44 +0100
commitc9423ca3fa65282b0ca58d33976c150f78e24f23 (patch)
tree294b7686614c59eae2c0a4ac8ed8cd7342de0f82 /gcc/ada/a-convec.adb
parent72348e26a5b81571cf11491569d5487203425a0c (diff)
downloadgcc-c9423ca3fa65282b0ca58d33976c150f78e24f23.zip
gcc-c9423ca3fa65282b0ca58d33976c150f78e24f23.tar.gz
gcc-c9423ca3fa65282b0ca58d33976c150f78e24f23.tar.bz2
[multiple changes]
2012-01-10 Pascal Obry <obry@adacore.com> * prj-nmsc.adb (Check_Library_Attributes): Kill check for object/source directories for aggregate libraries. 2012-01-10 Matthew Heaney <heaney@adacore.com> * a-cdlili.adb, a-cdlili.ads, a-cihama.adb, a-cihama.ads, a-coinve.adb, a-coinve.ads, a-ciorse.adb, a-ciorse.ads, a-coorma.adb, a-coorma.ads, a-cborma.adb, a-cborma.ads, a-cidlli.adb, a-cidlli.ads, a-cimutr.adb, a-cimutr.ads, a-cihase.adb, a-cihase.ads, a-cohama.adb, a-cohama.ads, a-coorse.adb, a-coorse.ads, a-cbhama.adb, a-cbhama.ads, a-cborse.adb, a-cborse.ads, a-comutr.adb, a-comutr.ads, a-ciorma.adb, a-cobove.adb, a-ciorma.ads, a-cobove.ads, a-convec.adb, a-convec.ads, a-cohase.adb, a-cohase.ads, a-cbdlli.adb, a-cbdlli.ads, a-cbmutr.adb, a-cbmutr.ads, a-cbhase.adb, a-cbhase.ads (Reference, Constant_Reference): Declare container parameter as aliased in/in out. Code clean ups. 2012-01-10 Bob Duff <duff@adacore.com> * s-os_lib.ads: Improve comment. 2012-01-10 Geert Bosch <bosch@adacore.com> * s-gearop.adb (Forward_Eliminate): Avoid improper aliasing for complex Scalar. From-SVN: r183060
Diffstat (limited to 'gcc/ada/a-convec.adb')
-rw-r--r--gcc/ada/a-convec.adb89
1 files changed, 48 insertions, 41 deletions
diff --git a/gcc/ada/a-convec.adb b/gcc/ada/a-convec.adb
index f80dd3b..2e35235 100644
--- a/gcc/ada/a-convec.adb
+++ b/gcc/ada/a-convec.adb
@@ -478,6 +478,42 @@ package body Ada.Containers.Vectors is
end if;
end Clear;
+ ------------------------
+ -- Constant_Reference --
+ ------------------------
+
+ function Constant_Reference
+ (Container : aliased Vector;
+ 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 denotes wrong container";
+ end if;
+
+ if Position.Index > Position.Container.Last then
+ raise Constraint_Error with "Position cursor is out of range";
+ end if;
+
+ return (Element => Container.Elements.EA (Position.Index)'Access);
+ end Constant_Reference;
+
+ function Constant_Reference
+ (Container : aliased Vector;
+ Index : Index_Type) return Constant_Reference_Type
+ is
+ begin
+ if Index > Container.Last then
+ raise Constraint_Error with "Index is out of range";
+ else
+ return (Element => Container.Elements.EA (Index)'Access);
+ end if;
+ end Constant_Reference;
+
--------------
-- Contains --
--------------
@@ -2538,64 +2574,35 @@ package body Ada.Containers.Vectors is
-- Reference --
---------------
- function Constant_Reference
- (Container : Vector;
- Position : Cursor) -- SHOULD BE ALIASED
- return Constant_Reference_Type
+ function Reference
+ (Container : aliased in out Vector;
+ 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.Index > Position.Container.Last then
- raise Constraint_Error with "Position cursor is out of range";
- end if;
-
- return
- (Element =>
- Position.Container.Elements.EA (Position.Index)'Access);
- end Constant_Reference;
-
- function Constant_Reference
- (Container : Vector;
- Position : Index_Type)
- return Constant_Reference_Type
- is
- begin
- if Position > Container.Last then
- raise Constraint_Error with "Index is out of range";
- else
- return (Element => Container.Elements.EA (Position)'Access);
- end if;
- end Constant_Reference;
-
- function Reference (Container : Vector; Position : Cursor)
- return Reference_Type is
- begin
- pragma Unreferenced (Container);
-
- if Position.Container = null then
- raise Constraint_Error with "Position cursor has no element";
+ if Position.Container /= Container'Unrestricted_Access then
+ raise Program_Error with "Position cursor denotes wrong container";
end if;
if Position.Index > Position.Container.Last then
raise Constraint_Error with "Position cursor is out of range";
end if;
- return
- (Element => Position.Container.Elements.EA (Position.Index)'Access);
+ return (Element => Container.Elements.EA (Position.Index)'Access);
end Reference;
- function Reference (Container : Vector; Position : Index_Type)
- return Reference_Type is
+ function Reference
+ (Container : aliased in out Vector;
+ Index : Index_Type) return Reference_Type
+ is
begin
- if Position > Container.Last then
+ if Index > Container.Last then
raise Constraint_Error with "Index is out of range";
else
- return (Element => Container.Elements.EA (Position)'Access);
+ return (Element => Container.Elements.EA (Index)'Access);
end if;
end Reference;