aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/table.adb
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2019-08-14 09:52:06 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-08-14 09:52:06 +0000
commitae3a2b54d1a19f9ca4941645f71dddf675fbd19c (patch)
treea554b76fa2c23e4a5845dcbc2356eb24d1d1e554 /gcc/ada/table.adb
parent27af94e7b9a4702ea93348f917fd2ad82adb6853 (diff)
downloadgcc-ae3a2b54d1a19f9ca4941645f71dddf675fbd19c.zip
gcc-ae3a2b54d1a19f9ca4941645f71dddf675fbd19c.tar.gz
gcc-ae3a2b54d1a19f9ca4941645f71dddf675fbd19c.tar.bz2
[Ada] Strengthen Locked flag
This patch strengthens the Locked flag, by Asserting that it is False on operations that might cause reallocation. No change in behavior (except in the presence of compiler bugs), so no test. 2019-08-14 Bob Duff <duff@adacore.com> gcc/ada/ * table.adb: Assert that the table is not locked when increasing Last, even if it doesn't cause reallocation. In other words, assert that on operations that MIGHT cause reallocation. * table.ads: Fix comment accordingly. From-SVN: r274463
Diffstat (limited to 'gcc/ada/table.adb')
-rw-r--r--gcc/ada/table.adb4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/ada/table.adb b/gcc/ada/table.adb
index ebbb857..9794047 100644
--- a/gcc/ada/table.adb
+++ b/gcc/ada/table.adb
@@ -80,6 +80,7 @@ package body Table is
procedure Append (New_Val : Table_Component_Type) is
begin
+ pragma Assert (not Locked);
Set_Item (Table_Index_Type (Last_Val + 1), New_Val);
end Append;
@@ -120,6 +121,7 @@ package body Table is
procedure Increment_Last is
begin
+ pragma Assert (not Locked);
Last_Val := Last_Val + 1;
if Last_Val > Max then
@@ -384,6 +386,8 @@ package body Table is
procedure Set_Last (New_Val : Table_Index_Type) is
begin
+ pragma Assert (Int (New_Val) <= Last_Val or else not Locked);
+
if Int (New_Val) < Last_Val then
Last_Val := Int (New_Val);