diff options
author | Jose Ruiz <ruiz@adacore.com> | 2024-08-23 16:25:13 +0000 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-09-05 10:10:12 +0200 |
commit | 47a30d6981db282a4a0e74cf02ff60a3eb0c14cf (patch) | |
tree | 9715660e1725dcd3a37b3116ec1320f92a93e4b8 | |
parent | 87023e0c7cd3aadb2ef60aa2592ba34d0ab8a5af (diff) | |
download | gcc-47a30d6981db282a4a0e74cf02ff60a3eb0c14cf.zip gcc-47a30d6981db282a4a0e74cf02ff60a3eb0c14cf.tar.gz gcc-47a30d6981db282a4a0e74cf02ff60a3eb0c14cf.tar.bz2 |
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.
-rw-r--r-- | gcc/ada/ali-util.adb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/gcc/ada/ali-util.adb b/gcc/ada/ali-util.adb index 61dddb9..4bcb06e 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; |