From 0f2d27e5fe82467329e0bbe8295bb4857b5da53c Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 18 May 2020 22:36:49 +0200 Subject: [PATCH] [Ada] Fix inaccurate -gnatR output for derived untagged types gcc/ada/ * repinfo.adb (Compute_Max_Length): Skip hidden discriminants. (List_Record_Layout): Likewise. (List_Structural_Record_Layout): Use First_Discriminant instead of First_Stored_Discriminant and Next_Discriminant instead of Next_Stored_Discriminant to walk the list of discriminants. --- gcc/ada/repinfo.adb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index 1d6be9a985c..1b6eb8a8abf 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -1006,10 +1006,12 @@ package body Repinfo is Comp := First_Component_Or_Discriminant (Ent); while Present (Comp) loop - -- Skip discriminant in unchecked union (since it is not there!) + -- Skip a completely hidden discriminant or a discriminant in an + -- unchecked union (since it is not there). if Ekind (Comp) = E_Discriminant - and then Is_Unchecked_Union (Ent) + and then (Is_Completely_Hidden (Comp) + or else Is_Unchecked_Union (Ent)) then goto Continue; end if; @@ -1278,10 +1280,12 @@ package body Repinfo is Comp := First_Component_Or_Discriminant (Ent); while Present (Comp) loop - -- Skip discriminant in unchecked union (since it is not there!) + -- Skip a completely hidden discriminant or a discriminant in an + -- unchecked union (since it is not there). if Ekind (Comp) = E_Discriminant - and then Is_Unchecked_Union (Ent) + and then (Is_Completely_Hidden (Comp) + or else Is_Unchecked_Union (Ent)) then goto Continue; end if; @@ -1370,7 +1374,7 @@ package body Repinfo is Derived_Disc : Entity_Id; begin - Derived_Disc := First_Stored_Discriminant (Outer_Ent); + Derived_Disc := First_Discriminant (Outer_Ent); -- Loop over the discriminants of the extension @@ -1394,7 +1398,7 @@ package body Repinfo is end if; end if; - Next_Stored_Discriminant (Derived_Disc); + Next_Discriminant (Derived_Disc); end loop; -- Disc is not constrained by a discriminant of Outer_Ent @@ -1463,12 +1467,13 @@ package body Repinfo is end if; -- If the record has discriminants and is not an unchecked - -- union, then display them now. + -- union, then display them now. Note that, even if this is + -- a structural layout, we list the visible discriminants. if Has_Discriminants (Ent) and then not Is_Unchecked_Union (Ent) then - Disc := First_Stored_Discriminant (Ent); + Disc := First_Discriminant (Ent); while Present (Disc) loop -- If this is a record extension and the discriminant is @@ -1506,7 +1511,7 @@ package body Repinfo is List_Component_Layout (Listed_Disc, Indent => Indent); <> - Next_Stored_Discriminant (Disc); + Next_Discriminant (Disc); end loop; end if; -- 2.30.2