public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4005] [Ada] Improve error message for .ali file version mismatch
@ 2021-10-01 6:14 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-10-01 6:14 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:cafd1c1a71325c0e9dc6a6862fdd5dcd7248fbb6
commit r12-4005-gcafd1c1a71325c0e9dc6a6862fdd5dcd7248fbb6
Author: Steve Baird <baird@adacore.com>
Date: Thu Aug 5 11:18:19 2021 -0700
[Ada] Improve error message for .ali file version mismatch
gcc/ada/
* bcheck.adb (Check_Versions): In the case of an ali file
version mismatch, if distinct integer values can be extracted
from the two version strings then include those values in the
generated error message.
Diff:
---
gcc/ada/bcheck.adb | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 72 insertions(+), 4 deletions(-)
diff --git a/gcc/ada/bcheck.adb b/gcc/ada/bcheck.adb
index 804e2fd5d16..bf53b4be25d 100644
--- a/gcc/ada/bcheck.adb
+++ b/gcc/ada/bcheck.adb
@@ -29,6 +29,7 @@ with Binderr; use Binderr;
with Butil; use Butil;
with Casing; use Casing;
with Fname; use Fname;
+with Gnatvsn;
with Namet; use Namet;
with Opt; use Opt;
with Osint;
@@ -1324,11 +1325,78 @@ package body Bcheck is
or else ALIs.Table (A).Ver (1 .. VL) /=
ALIs.Table (ALIs.First).Ver (1 .. VL)
then
- Error_Msg_File_1 := ALIs.Table (A).Sfile;
- Error_Msg_File_2 := ALIs.Table (ALIs.First).Sfile;
+ declare
+ No_Version : constant Int := -1;
- Consistency_Error_Msg
- ("{ and { compiled with different GNAT versions");
+ function Extract_Version (S : String) return Int;
+ -- Attempts to extract and return a nonnegative library
+ -- version number from the given string; if unsuccessful,
+ -- then returns No_Version.
+
+ ---------------------
+ -- Extract_Version --
+ ---------------------
+
+ function Extract_Version (S : String) return Int is
+ use Gnatvsn;
+
+ Prefix : constant String :=
+ Verbose_Library_Version
+ (1 .. Verbose_Library_Version'Length
+ - Library_Version'Length);
+ begin
+ pragma Assert (S'First = 1);
+
+ if S'Length > Prefix'Length
+ and then S (1 .. Prefix'Length) = Prefix
+ then
+ declare
+ Suffix : constant String :=
+ S (1 + Prefix'Length .. S'Last);
+
+ Result : Nat := 0;
+ begin
+ if Suffix'Length < 10
+ and then (for all C of Suffix => C in '0' .. '9')
+ then
+ -- Using Int'Value leads to complications in
+ -- building the binder, so DIY.
+
+ for C of Suffix loop
+ Result := (10 * Result) +
+ (Character'Pos (C) - Character'Pos ('0'));
+ end loop;
+ return Result;
+ end if;
+ end;
+ end if;
+ return No_Version;
+ end Extract_Version;
+
+ V1_Text : constant String :=
+ ALIs.Table (A).Ver (1 .. ALIs.Table (A).Ver_Len);
+ V2_Text : constant String :=
+ ALIs.Table (ALIs.First).Ver (1 .. VL);
+ V1 : constant Int := Extract_Version (V1_Text);
+ V2 : constant Int := Extract_Version (V2_Text);
+
+ Include_Version_Numbers_In_Message : constant Boolean :=
+ (V1 /= V2) and (V1 /= No_Version) and (V2 /= No_Version);
+ begin
+ Error_Msg_File_1 := ALIs.Table (A).Sfile;
+ Error_Msg_File_2 := ALIs.Table (ALIs.First).Sfile;
+
+ if Include_Version_Numbers_In_Message then
+ Error_Msg_Nat_1 := V1;
+ Error_Msg_Nat_2 := V2;
+ Consistency_Error_Msg
+ ("{ and { compiled with different GNAT versions"
+ & ", v# and v#");
+ else
+ Consistency_Error_Msg
+ ("{ and { compiled with different GNAT versions");
+ end if;
+ end;
end if;
end loop;
end Check_Versions;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-01 6:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 6:14 [gcc r12-4005] [Ada] Improve error message for .ali file version mismatch Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).