https://gcc.gnu.org/g:566ca645e4ba676df1f5ae4bf4767b4ecf69bdf1
commit r16-5468-g566ca645e4ba676df1f5ae4bf4767b4ecf69bdf1 Author: Eric Botcazou <[email protected]> Date: Mon Nov 10 12:44:47 2025 +0100 ada: Remove suspicious entries generated by -gnatR for generic formal types Generic formal type parameters may have an unspecified layout when they are processed for the -gnatR output, so it's better to skip them entirely. The change also reverts an earlier change that would output "??" for an unknown alignment on a type, which is inconsistent and undocumented. gcc/ada/ChangeLog: * repinfo.adb (List_Location): Do not output the final comma. (List_Common_Type_Info): Adjust to above change. Do not output "??" for an unknown alignment. (List_Entities): Do not output generic types. (List_Object_Info): Adjust to above change. (List_Subprogram_Info): Likewise. Diff: --- gcc/ada/repinfo.adb | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index 41afbb7ecbf6..a8cb126d1929 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -362,9 +362,9 @@ package body Repinfo is if Esize (Ent) = RM_Size (Ent) then if List_Representation_Info_To_JSON then + Write_Line (","); Write_Str (" ""Size"": "); Write_Val (Esize (Ent)); - Write_Line (","); else Write_Str ("for "); List_Name (Ent); @@ -377,13 +377,13 @@ package body Repinfo is else if List_Representation_Info_To_JSON then + Write_Line (","); Write_Str (" ""Object_Size"": "); Write_Val (Esize (Ent)); - Write_Line (","); + Write_Line (","); Write_Str (" ""Value_Size"": "); Write_Val (RM_Size (Ent)); - Write_Line (","); else Write_Str ("for "); @@ -404,6 +404,7 @@ package body Repinfo is if Known_Alignment (Ent) then if List_Representation_Info_To_JSON then + Write_Line (","); Write_Str (" ""Alignment"": "); Write_Val (Alignment (Ent)); else @@ -419,14 +420,6 @@ package body Repinfo is -- aspects are not computed for types declared in a generic unit. else - -- Add unknown alignment entry in JSON format to ensure the format is - -- valid, as a comma is added by the caller before another field. - - if List_Representation_Info_To_JSON then - Write_Str (" ""Alignment"": "); - Write_Unknown_Val; - end if; - pragma Assert (not Expander_Active or else Is_Concurrent_Type (Ent) or else Is_Class_Wide_Type (Ent) @@ -471,12 +464,13 @@ package body Repinfo is E := First_Entity (Ent); while Present (E) loop - -- We list entities that come from source (excluding private or - -- incomplete types or deferred constants, for which we will list - -- the information for the full view). If requested, we also list - -- relevant entities that have been generated when processing the - -- original entities coming from source. But if debug flag A is - -- set, then all entities are listed. + -- We list entities that come from source (except for incomplete, + -- private and generic types, as well as deferred constants, for + -- which we list the information for the full view). If requested + -- by the -gnatR4 switch, we also list relevant entities that have + -- been created when processing the original entities coming from + -- source. If debug switch -gnatdA is specified, then all entities + -- are listed. if ((Comes_From_Source (E) or else (Ekind (E) = E_Block @@ -484,9 +478,10 @@ package body Repinfo is Nkind (Parent (E)) = N_Implicit_Label_Declaration and then Comes_From_Source (Label_Construct (Parent (E))))) - and then not Is_Incomplete_Or_Private_Type (E) - and then not (Ekind (E) = E_Constant - and then Present (Full_View (E)))) + and then not Is_Incomplete_Or_Private_Type (E) + and then not Is_Generic_Type (E) + and then not (Ekind (E) = E_Constant + and then Present (Full_View (E)))) or else (List_Representation_Info = 4 and then Relevant_Entities.Get (E)) or else Debug_Flag_AA @@ -813,7 +808,7 @@ package body Repinfo is pragma Assert (List_Representation_Info_To_JSON); Write_Str (" ""location"": """); Write_Location (Sloc (Ent)); - Write_Line (""","); + Write_Str (""""); end List_Location; --------------- @@ -874,6 +869,7 @@ package body Repinfo is List_Name (Ent); Write_Line (""","); List_Location (Ent); + Write_Line (","); Write_Str (" ""Size"": "); Write_Val (Esize (Ent)); @@ -2039,6 +2035,7 @@ package body Repinfo is List_Name (Ent); Write_Line (""","); List_Location (Ent); + Write_Line (","); Write_Str (" ""Convention"": """); else
