From: Ronan Desplanques <[email protected]>
Table.Table can be instantiated to use either 0-based or 1-based
indexing, which can cause some confusion and make 0-based instances get
used as 1-based ones.
This was the case for two tables in Fmap before this patch. That did not
cause any bugs but allocated an extra cell in the arrays that went
unused.
This patch also replaces Increment_Last-and-assignment combos with
equivalent calls to Append.
gcc/ada/ChangeLog:
* fmap.adb (File_Mapping, Path_Mapping): Fix instantiations.
(Add_To_File_Map): Use Table.Table.Append.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/fmap.adb | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/gcc/ada/fmap.adb b/gcc/ada/fmap.adb
index f5e0540e0f8..4f20231365d 100644
--- a/gcc/ada/fmap.adb
+++ b/gcc/ada/fmap.adb
@@ -58,7 +58,7 @@ package body Fmap is
package File_Mapping is new Table.Table (
Table_Component_Type => Mapping,
Table_Index_Type => Int,
- Table_Low_Bound => 0,
+ Table_Low_Bound => 1,
Table_Initial => 1_000,
Table_Increment => 1_000,
Table_Name => "Fmap.File_Mapping");
@@ -67,7 +67,7 @@ package body Fmap is
package Path_Mapping is new Table.Table (
Table_Component_Type => Mapping,
Table_Index_Type => Int,
- Table_Low_Bound => 0,
+ Table_Low_Bound => 1,
Table_Initial => 1_000,
Table_Increment => 1_000,
Table_Name => "Fmap.Path_Mapping");
@@ -121,19 +121,15 @@ package body Fmap is
if Unit_Entry = No_Entry or else
File_Mapping.Table (Unit_Entry).Fname /= File_Name
then
- File_Mapping.Increment_Last;
+ File_Mapping.Append ((Uname => Unit_Name, Fname => File_Name));
Unit_Hash_Table.Set (Unit_Name, File_Mapping.Last);
- File_Mapping.Table (File_Mapping.Last) :=
- (Uname => Unit_Name, Fname => File_Name);
end if;
if File_Entry = No_Entry or else
Path_Mapping.Table (File_Entry).Fname /= Path_Name
then
- Path_Mapping.Increment_Last;
+ Path_Mapping.Append ((Uname => Unit_Name, Fname => Path_Name));
File_Hash_Table.Set (File_Name, Path_Mapping.Last);
- Path_Mapping.Table (Path_Mapping.Last) :=
- (Uname => Unit_Name, Fname => Path_Name);
end if;
end Add_To_File_Map;
--
2.43.0