aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGhjuvan Lacambre <lacambre@adacore.com>2022-05-17 20:03:44 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2022-06-02 09:06:42 +0000
commit8575c72f04019a5ffc6be359e1d513bb2e1fb2d8 (patch)
treee8af4784ceabb61a4b7d9c8a1063022ed35dd21f /gcc
parent615682bc665e17f5b38e12878a1fa98f5062b5e4 (diff)
downloadgcc-8575c72f04019a5ffc6be359e1d513bb2e1fb2d8.zip
gcc-8575c72f04019a5ffc6be359e1d513bb2e1fb2d8.tar.gz
gcc-8575c72f04019a5ffc6be359e1d513bb2e1fb2d8.tar.bz2
[Ada] Add precise subprogram identification to -fdiagnostics-format=json
This commit adds information allowing identification of the subprogram surrounding the message emitted by gnat when using -gnatdJ along with -fdiagnostics-format=json. gcc/ada/ * errout.adb (Write_JSON_Span): Add subprogram name to emitted JSON.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/errout.adb21
1 files changed, 15 insertions, 6 deletions
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index e3aa0ed..4e095a7 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -2097,11 +2097,14 @@ package body Errout is
-- Write Sptr as a JSON location, an object containing a file attribute,
-- a line number and a column number.
- procedure Write_JSON_Span (Span : Source_Span);
- -- Write Span as a JSON span, an object containing a "caret" attribute
- -- whose value is the JSON location of Span.Ptr. If Span.First and
- -- Span.Last are different from Span.Ptr, they will be printed as JSON
+ procedure Write_JSON_Span (Error : Error_Msg_Object);
+ -- Write Error as a JSON span, an object containing a "caret" attribute
+ -- whose value is the JSON location of Error.Sptr.Ptr. If Sptr.First and
+ -- Sptr.Last are different from Sptr.Ptr, they will be printed as JSON
-- locations under the names "start" and "finish".
+ -- When Include_Subprogram_In_Messages is true (-gnatdJ) an additional,
+ -- non-standard, attribute named "subprogram" will be added, allowing
+ -- precisely identifying the subprogram surrounding the span.
-----------------------
-- Is_Continuation --
@@ -2162,7 +2165,8 @@ package body Errout is
-- Write_JSON_Span --
---------------------
- procedure Write_JSON_Span (Span : Source_Span) is
+ procedure Write_JSON_Span (Error : Error_Msg_Object) is
+ Span : constant Source_Span := Error.Sptr;
begin
Write_Str ("{""caret"":");
Write_JSON_Location (Span.Ptr);
@@ -2177,6 +2181,11 @@ package body Errout is
Write_JSON_Location (Span.Last);
end if;
+ if Include_Subprogram_In_Messages then
+ Write_Str
+ (",""subprogram"":""" & Subprogram_Name_Ptr (Error.Node) & """");
+ end if;
+
Write_Str ("}");
end Write_JSON_Span;
@@ -2210,7 +2219,7 @@ package body Errout is
-- Print message location
Write_Str (",""locations"":[");
- Write_JSON_Span (Errors.Table (E).Sptr);
+ Write_JSON_Span (Errors.Table (E));
if Errors.Table (E).Optr /= Errors.Table (E).Sptr.Ptr then
Write_Str (",{""caret"":");