aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-05-18 22:36:49 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-08 10:55:50 -0400
commit0f2d27e5fe82467329e0bbe8295bb4857b5da53c (patch)
tree8caf70e6411b70b15ba0bc184c32317fe42f0632 /gcc
parent530b30d9b3c2b60a5dfc8b3323b886ef5fed41a1 (diff)
downloadgcc-0f2d27e5fe82467329e0bbe8295bb4857b5da53c.zip
gcc-0f2d27e5fe82467329e0bbe8295bb4857b5da53c.tar.gz
gcc-0f2d27e5fe82467329e0bbe8295bb4857b5da53c.tar.bz2
[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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/repinfo.adb23
1 files changed, 14 insertions, 9 deletions
diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb
index 1d6be9a..1b6eb8a 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);
<<Continue_Disc>>
- Next_Stored_Discriminant (Disc);
+ Next_Discriminant (Disc);
end loop;
end if;