From: Ronan Desplanques Date: Thu, 25 Sep 2025 07:53:35 +0000 (+0200) Subject: ada: Fix usage of Table.Table in Fmap X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e77f62626f20fbe7aaf81f55f75e16b36632ff38;p=thirdparty%2Fgcc.git ada: Fix usage of Table.Table in Fmap 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. --- 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;