summaryrefslogtreecommitdiff
path: root/gcc/ada/a-cobove.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/a-cobove.adb')
-rw-r--r--gcc/ada/a-cobove.adb37
1 files changed, 30 insertions, 7 deletions
diff --git a/gcc/ada/a-cobove.adb b/gcc/ada/a-cobove.adb
index 99659abc795..aaf69c31213 100644
--- a/gcc/ada/a-cobove.adb
+++ b/gcc/ada/a-cobove.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2004-2011, Free Software Foundation, Inc. --
+-- Copyright (C) 2004-2012, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -931,8 +931,7 @@ package body Ada.Containers.Bounded_Vectors is
-- Sort --
----------
- procedure Sort (Container : in out Vector)
- is
+ procedure Sort (Container : in out Vector) is
procedure Sort is
new Generic_Array_Sort
(Index_Type => Count_Type,
@@ -940,14 +939,27 @@ package body Ada.Containers.Bounded_Vectors is
Array_Type => Elements_Array,
"<" => "<");
+ -- Start of processing for Sort
+
begin
if Container.Last <= Index_Type'First then
return;
end if;
- if Container.Lock > 0 then
+ -- The exception behavior for the vector container must match that
+ -- for the list container, so we check for cursor tampering here
+ -- (which will catch more things) instead of for element tampering
+ -- (which will catch fewer things). It's true that the elements of
+ -- this vector container could be safely moved around while (say) an
+ -- iteration is taking place (iteration only increments the busy
+ -- counter), and so technically all we would need here is a test for
+ -- element tampering (indicated by the lock counter), that's simply
+ -- an artifact of our array-based implementation. Logically Sort
+ -- requires a check for cursor tampering.
+
+ if Container.Busy > 0 then
raise Program_Error with
- "attempt to tamper with elements (vector is locked)";
+ "attempt to tamper with cursors (vector is busy)";
end if;
Sort (Container.Elements (1 .. Container.Length));
@@ -2234,9 +2246,20 @@ package body Ada.Containers.Bounded_Vectors is
return;
end if;
- if Container.Lock > 0 then
+ -- The exception behavior for the vector container must match that for
+ -- the list container, so we check for cursor tampering here (which will
+ -- catch more things) instead of for element tampering (which will catch
+ -- fewer things). It's true that the elements of this vector container
+ -- could be safely moved around while (say) an iteration is taking place
+ -- (iteration only increments the busy counter), and so technically all
+ -- we would need here is a test for element tampering (indicated by the
+ -- lock counter), that's simply an artifact of our array-based
+ -- implementation. Logically Reverse_Elements requires a check for
+ -- cursor tampering.
+
+ if Container.Busy > 0 then
raise Program_Error with
- "attempt to tamper with elements (vector is locked)";
+ "attempt to tamper with cursors (vector is busy)";
end if;
Idx := 1;