+2019-08-14 Bob Duff <duff@adacore.com>
+
+ * 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.
+
2019-08-14 Arnaud Charlet <charlet@adacore.com>
* doc/gnat_ugn/gnat_and_program_execution.rst: Remove
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;
procedure Increment_Last is
begin
+ pragma Assert (not Locked);
Last_Val := Last_Val + 1;
if Last_Val > Max then
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);
-- First .. Last.
Locked : Boolean := False;
- -- Table expansion is permitted only if this switch is set to False. A
- -- client may set Locked to True, in which case any attempt to expand
- -- the table will cause an assertion failure. Note that while a table
- -- is locked, its address in memory remains fixed and unchanging. This
- -- feature is used to control table expansion during Gigi processing.
- -- Gigi assumes that tables other than the Uint and Ureal tables do
- -- not move during processing, which means that they cannot be expanded.
- -- The Locked flag is used to enforce this restriction.
+ -- Increasing the value of Last is permitted only if this switch is set
+ -- to False. A client may set Locked to True, in which case any attempt
+ -- to increase the value of Last (which might expand the table) will
+ -- cause an assertion failure. Note that while a table is locked, its
+ -- address in memory remains fixed and unchanging. This feature is used
+ -- to control table expansion during Gigi processing. Gigi assumes that
+ -- tables other than the Uint and Ureal tables do not move during
+ -- processing, which means that they cannot be expanded. The Locked
+ -- flag is used to enforce this restriction.
procedure Init;
-- This procedure allocates a new table of size Initial (freeing any