aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorViljar Indus <indus@adacore.com>2024-11-01 13:15:21 +0200
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-11-26 10:49:34 +0100
commit20e7dfa9fb7db0cd45ad80d8e0592bd1fc7caad0 (patch)
tree6823537b949779c8de41ff3619aa39cde6c36d16 /gcc
parent7cdb07a77bac31dc39f8eea2e7eaabf99bbd00ab (diff)
downloadgcc-20e7dfa9fb7db0cd45ad80d8e0592bd1fc7caad0.zip
gcc-20e7dfa9fb7db0cd45ad80d8e0592bd1fc7caad0.tar.gz
gcc-20e7dfa9fb7db0cd45ad80d8e0592bd1fc7caad0.tar.bz2
ada: Refactor code for printing the error location
gcc/ada/ChangeLog: * errout.adb: Use Output_Msg_Location * erroutc.adb: add common implementation for printing the error message line. * erroutc.ads: Add new method Output_Msg_Location * errutil.adb: use Output_Msg_Location
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/errout.adb23
-rw-r--r--gcc/ada/erroutc.adb29
-rw-r--r--gcc/ada/erroutc.ads7
-rw-r--r--gcc/ada/errutil.adb19
4 files changed, 38 insertions, 40 deletions
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 21c8adf..de2413a 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -2635,28 +2635,7 @@ package body Errout is
end if;
if Use_Prefix then
- Write_Str (SGR_Locus);
-
- if Full_Path_Name_For_Brief_Errors then
- Write_Name (Full_Ref_Name (Errors.Table (E).Sfile));
- else
- Write_Name (Reference_Name (Errors.Table (E).Sfile));
- end if;
-
- Write_Char (':');
- Write_Int (Int (Physical_To_Logical
- (Errors.Table (E).Line,
- Errors.Table (E).Sfile)));
- Write_Char (':');
-
- if Errors.Table (E).Col < 10 then
- Write_Char ('0');
- end if;
-
- Write_Int (Int (Errors.Table (E).Col));
- Write_Str (": ");
-
- Write_Str (SGR_Reset);
+ Output_Msg_Location (E);
end if;
Output_Msg_Text (E);
diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb
index db1c092..606600c 100644
--- a/gcc/ada/erroutc.adb
+++ b/gcc/ada/erroutc.adb
@@ -774,6 +774,35 @@ package body Erroutc is
end loop;
end Output_Text_Within;
+ -------------------------
+ -- Output_Msg_Location --
+ -------------------------
+
+ procedure Output_Msg_Location (E : Error_Msg_Id) is
+ E_Obj : constant Error_Msg_Object := Errors.Table (E);
+ begin
+ Write_Str (SGR_Locus);
+
+ if Full_Path_Name_For_Brief_Errors then
+ Write_Name (Full_Ref_Name (E_Obj.Sfile));
+ else
+ Write_Name (Reference_Name (E_Obj.Sfile));
+ end if;
+
+ Write_Char (':');
+ Write_Int (Int (Physical_To_Logical (E_Obj.Line, E_Obj.Sfile)));
+ Write_Char (':');
+
+ if E_Obj.Col < 10 then
+ Write_Char ('0');
+ end if;
+
+ Write_Int (Int (E_Obj.Col));
+ Write_Str (": ");
+
+ Write_Str (SGR_Reset);
+ end Output_Msg_Location;
+
---------------------
-- Output_Msg_Text --
---------------------
diff --git a/gcc/ada/erroutc.ads b/gcc/ada/erroutc.ads
index 0a52af5..6c3b9da 100644
--- a/gcc/ada/erroutc.ads
+++ b/gcc/ada/erroutc.ads
@@ -512,6 +512,13 @@ package Erroutc is
-- that match or are less than the last Source_Reference pragma are listed
-- as all blanks, avoiding output of junk line numbers.
+ procedure Output_Msg_Location (E : Error_Msg_Id);
+ -- Write the location of the error message in the following format:
+ --
+ -- <File_Name>:<Line>:<Col>:
+ --
+ -- If Full_Path_Name_For_Brief_Errors then full path of the file is used.
+
procedure Output_Msg_Text (E : Error_Msg_Id);
-- Outputs characters of text in the text of the error message E. Note that
-- no end of line is output, the caller is responsible for adding the end
diff --git a/gcc/ada/errutil.adb b/gcc/ada/errutil.adb
index 6747fe5..795b2f2 100644
--- a/gcc/ada/errutil.adb
+++ b/gcc/ada/errutil.adb
@@ -411,24 +411,7 @@ package body Errutil is
while E /= No_Error_Msg loop
if not Errors.Table (E).Deleted then
- if Full_Path_Name_For_Brief_Errors then
- Write_Name (Full_Ref_Name (Errors.Table (E).Sfile));
- else
- Write_Name (Reference_Name (Errors.Table (E).Sfile));
- end if;
-
- Write_Char (':');
- Write_Int (Int (Physical_To_Logical
- (Errors.Table (E).Line,
- Errors.Table (E).Sfile)));
- Write_Char (':');
-
- if Errors.Table (E).Col < 10 then
- Write_Char ('0');
- end if;
-
- Write_Int (Int (Errors.Table (E).Col));
- Write_Str (": ");
+ Output_Msg_Location (E);
Output_Msg_Text (E);
Write_Eol;
end if;