summaryrefslogtreecommitdiff
path: root/gcc/ada/a-coinve.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-10 11:06:44 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-10 11:06:44 +0000
commitae8e99a36859a079b40a4693302062976a537f05 (patch)
tree294b7686614c59eae2c0a4ac8ed8cd7342de0f82 /gcc/ada/a-coinve.adb
parent43537c9651f05e0ad6ba2c752dcfdfb762ef8376 (diff)
downloadgcc-ae8e99a36859a079b40a4693302062976a537f05.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183060 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-coinve.adb')
-rw-r--r--gcc/ada/a-coinve.adb71
1 files changed, 52 insertions, 19 deletions
diff --git a/gcc/ada/a-coinve.adb b/gcc/ada/a-coinve.adb
index b845e6fc7ff..92c08749d9a 100644
--- a/gcc/ada/a-coinve.adb
+++ b/gcc/ada/a-coinve.adb
@@ -673,34 +673,51 @@ package body Ada.Containers.Indefinite_Vectors is
------------------------
function Constant_Reference
- (Container : Vector;
+ (Container : aliased Vector;
Position : Cursor) return Constant_Reference_Type
is
- begin
- pragma Unreferenced (Container);
+ E : Element_Access;
+ 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 => Position.Container.Elements.EA (Position.Index).all'Access);
+ E := Container.Elements.EA (Position.Index);
+
+ if E = null then
+ raise Constraint_Error with "element at Position is empty";
+ end if;
+
+ return (Element => E.all'Access);
end Constant_Reference;
function Constant_Reference
- (Container : Vector;
- Position : Index_Type) return Constant_Reference_Type
+ (Container : aliased Vector;
+ Index : Index_Type) return Constant_Reference_Type
is
+ E : Element_Access;
+
begin
- if (Position) > Container.Last then
+ if Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
- return (Element => Container.Elements.EA (Position).all'Access);
+ E := Container.Elements.EA (Index);
+
+ if E = null then
+ raise Constraint_Error with "element at Index is empty";
+ end if;
+
+ return (Element => E.all'Access);
end Constant_Reference;
--------------
@@ -2998,35 +3015,51 @@ package body Ada.Containers.Indefinite_Vectors is
---------------
function Reference
- (Container : Vector;
+ (Container : aliased in out Vector;
Position : Cursor) return Reference_Type
is
- begin
- pragma Unreferenced (Container);
+ E : Element_Access;
+ 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 =>
- Position.Container.Elements.EA (Position.Index).all'Access);
+ E := Container.Elements.EA (Position.Index);
+
+ if E = null then
+ raise Constraint_Error with "element at Position is empty";
+ end if;
+
+ return (Element => E.all'Access);
end Reference;
function Reference
- (Container : Vector;
- Position : Index_Type) return Reference_Type
+ (Container : aliased in out Vector;
+ Index : Index_Type) return Reference_Type
is
+ E : Element_Access;
+
begin
- if Position > Container.Last then
+ if Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
- return (Element => Container.Elements.EA (Position).all'Access);
+ E := Container.Elements.EA (Index);
+
+ if E = null then
+ raise Constraint_Error with "element at Index is empty";
+ end if;
+
+ return (Element => E.all'Access);
end Reference;
---------------------