:switch:`-fdiagnostics-format=json`
Makes GNAT emit warning and error messages as JSON. Inhibits printing of
text warning and errors messages except if :switch:`-gnatv` or
- :switch:`-gnatl` are present.
+ :switch:`-gnatl` are present. Uses absolute file paths when used along
+ :switch:`-gnatef`.
.. index:: -fdump-scos (gcc)
.. index:: -gnatef (gcc)
:switch:`-gnatef`
- Display full source path name in brief error messages.
+ Display full source path name in brief error messages and absolute paths in
+ :switch:`-fdiagnostics-format=json`'s output.
.. index:: -gnateF (gcc)
with Snames; use Snames;
with Stand; use Stand;
with Stylesw; use Stylesw;
+with System.OS_Lib;
with Uname; use Uname;
package body Errout is
-- Return True if E is a continuation message.
procedure Write_JSON_Escaped_String (Str : String_Ptr);
+ procedure Write_JSON_Escaped_String (Str : String);
-- Write each character of Str, taking care of preceding each quote and
-- backslash with a backslash. Note that this escaping differs from what
-- GCC does.
-- Write_JSON_Escaped_String --
-------------------------------
- procedure Write_JSON_Escaped_String (Str : String_Ptr) is
+ procedure Write_JSON_Escaped_String (Str : String) is
begin
- for C of Str.all loop
+ for C of Str loop
if C = '"' or else C = '\' then
Write_Char ('\');
end if;
end loop;
end Write_JSON_Escaped_String;
+ -------------------------------
+ -- Write_JSON_Escaped_String --
+ -------------------------------
+
+ procedure Write_JSON_Escaped_String (Str : String_Ptr) is
+ begin
+ Write_JSON_Escaped_String (Str.all);
+ end Write_JSON_Escaped_String;
+
-------------------------
-- Write_JSON_Location --
-------------------------
procedure Write_JSON_Location (Sptr : Source_Ptr) is
+ Name : constant File_Name_Type :=
+ Full_Ref_Name (Get_Source_File_Index (Sptr));
begin
Write_Str ("{""file"":""");
- Write_Name (Full_Ref_Name (Get_Source_File_Index (Sptr)));
+ if Full_Path_Name_For_Brief_Errors then
+ Write_JSON_Escaped_String
+ (System.OS_Lib.Normalize_Pathname (Get_Name_String (Name)));
+ else
+ Write_Name (Name);
+ end if;
Write_Str (""",""line"":");
Write_Int (Pos (Get_Physical_Line_Number (Sptr)));
Write_Str (", ""column"":");
@copying
@quotation
-GNAT User's Guide for Native Platforms , Apr 22, 2022
+GNAT User's Guide for Native Platforms , May 24, 2022
AdaCore
Makes GNAT emit warning and error messages as JSON. Inhibits printing of
text warning and errors messages except if @code{-gnatv} or
-@code{-gnatl} are present.
+@code{-gnatl} are present. Uses absolute file paths when used along
+@code{-gnatef}.
@end table
@geindex -fdump-scos (gcc)
@item @code{-gnatef}
-Display full source path name in brief error messages.
+Display full source path name in brief error messages and absolute paths in
+@code{-fdiagnostics-format=json}’s output.
@end table
@geindex -gnateF (gcc)
@printindex ge
-@anchor{cf}@w{ }
@anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{ }
+@anchor{cf}@w{ }
@c %**end of body
@bye