]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix unescaped quotes when combining fdiagnostics-format=json and gnatdJ
authorGhjuvan Lacambre <lacambre@adacore.com>
Mon, 12 Dec 2022 13:54:47 +0000 (14:54 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 3 Jan 2023 09:29:54 +0000 (10:29 +0100)
This commit fixes a small bug where GNAT would emit unescaped quotes in
its -fdiagnostics-format=json output when using -gnatdJ and emitting
messages about operator functions (e.g. "=").

gcc/ada/

* errout.adb (Write_JSON_Span): Escape subprogram name.

gcc/ada/errout.adb

index b30e8b51d159d89b900a90030d450376083834d7..261ba2e80331b3f4df652f59cb9e5f5a58773684 100644 (file)
@@ -2193,8 +2193,9 @@ package body Errout is
          end if;
 
          if Include_Subprogram_In_Messages then
-            Write_Str
-              (",""subprogram"":""" & Subprogram_Name_Ptr (Error.Node) & """");
+            Write_Str (",""subprogram"":""");
+            Write_JSON_Escaped_String (Subprogram_Name_Ptr (Error.Node));
+            Write_Str ("""");
          end if;
 
          Write_Str ("}");