https://gcc.gnu.org/g:47a30d6981db282a4a0e74cf02ff60a3eb0c14cf
commit r15-3469-g47a30d6981db282a4a0e74cf02ff60a3eb0c14cf Author: Jose Ruiz <r...@adacore.com> Date: Fri Aug 23 16:25:13 2024 +0000 ada: Binder respects Ada version for checksum of runtime files The parsing to compute the checksums of runtime files (within the binder) was done using the default Ada version (Ada 2012 currently), while the creation of the checksum, when the runtime files are compiled, is performed in a more recent Ada version (Ada 2022 currently). This change forces the checksum computation for runtime files to be done with the same Ada version as when they were created. gcc/ada/ * ali-util.adb (Get_File_Checksum): Force the parsing for the checksum computation of runtime files to be done in the corresponding recent Ada version. Diff: --- gcc/ada/ali-util.adb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gcc/ada/ali-util.adb b/gcc/ada/ali-util.adb index 61dddb94e85..4bcb06e6a1f 100644 --- a/gcc/ada/ali-util.adb +++ b/gcc/ada/ali-util.adb @@ -29,6 +29,7 @@ with Opt; use Opt; with Output; use Output; with Osint; use Osint; with Scans; use Scans; +with Fname; use Fname; with Scng; with Sinput.C; with Stringt; @@ -87,8 +88,10 @@ package body ALI.Util is ----------------------- function Get_File_Checksum (Fname : File_Name_Type) return Word is - Full_Name : File_Name_Type; - Source_Index : Source_File_Index; + Full_Name : File_Name_Type; + Source_Index : Source_File_Index; + Ada_Version_Current : Ada_Version_Type; + Internal_Unit : constant Boolean := Is_Internal_File_Name (Fname); begin Full_Name := Find_File (Fname, Osint.Source); @@ -109,6 +112,15 @@ package body ALI.Util is Scanner.Initialize_Scanner (Source_Index); + -- The runtime files are precompiled with an implicitly defined Ada + -- version that we set here to improve the parsing required to compute + -- the checksum. + + if Internal_Unit then + Ada_Version_Current := Ada_Version; + Ada_Version := Ada_Version_Runtime; + end if; + -- Scan the complete file to compute its checksum loop @@ -116,6 +128,12 @@ package body ALI.Util is exit when Token = Tok_EOF; end loop; + -- Restore the Ada version if we changed it + + if Internal_Unit then + Ada_Version := Ada_Version_Current; + end if; + return Scans.Checksum; end Get_File_Checksum;