From: Eric Botcazou Date: Tue, 9 Jul 2019 07:54:24 +0000 (+0000) Subject: [Ada] Missing escape of the double quote in JSON output X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fb95bfcc8138378d4e5786c67f5eb49b84a54683;p=gcc.git [Ada] Missing escape of the double quote in JSON output In Ada, the name of operators contains a pair of double quotes, which need to be properly escaped when the name appears in the JSON output of -gnatR. The change also ensures that formal parameters are not listed in the layout information, since this information is not back-annotated for them. 2019-07-09 Eric Botcazou gcc/ada/ * repinfo.adb (List_Entities): Disregard formals altogether. (List_Name): Properly escape the double quote in the JSON output. From-SVN: r273279 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index e5aba8b08fe..1dd1d705c21 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-07-09 Eric Botcazou + + * repinfo.adb (List_Entities): Disregard formals altogether. + (List_Name): Properly escape the double quote in the JSON + output. + 2019-07-09 Javier Miranda * exp_util.adb (Remove_Side_Effects): Preserve the diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index 75da2b6251b..1ba7e11e67c 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -525,9 +525,6 @@ package body Repinfo is List_Entities (E, Bytes_Big_Endian, True); - elsif Is_Formal (E) and then In_Subprogram then - null; - elsif Ekind_In (E, E_Entry, E_Entry_Family, E_Subprogram_Type) @@ -560,12 +557,10 @@ package body Repinfo is List_Type_Info (E); end if; - elsif Ekind_In (E, E_Variable, E_Constant) then - if List_Representation_Info >= 2 then - List_Object_Info (E); - end if; + -- Note that formals are not annotated so we skip them here - elsif Ekind (E) = E_Loop_Parameter or else Is_Formal (E) then + elsif Ekind_In (E, E_Variable, E_Constant, E_Loop_Parameter) + then if List_Representation_Info >= 2 then List_Object_Info (E); end if; @@ -899,6 +894,8 @@ package body Repinfo is --------------- procedure List_Name (Ent : Entity_Id) is + C : Character; + begin -- List the qualified name recursively, except -- at compilation unit level in default mode. @@ -914,7 +911,16 @@ package body Repinfo is Get_Unqualified_Decoded_Name_String (Chars (Ent)); Set_Casing (Unit_Casing); - Write_Str (Name_Buffer (1 .. Name_Len)); + + -- The name of operators needs to be properly escaped for JSON + + for J in 1 .. Name_Len loop + C := Name_Buffer (J); + if C = '"' and then List_Representation_Info_To_JSON then + Write_Char ('\'); + end if; + Write_Char (C); + end loop; end List_Name; ---------------------