summaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2020-06-13 08:21:19 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-16 05:18:20 -0400
commit135c02769b9ec625a55a0beba63415c1484f8951 (patch)
tree282d0c18a109b78e36c142b5703bcf1d5e1d5c24 /gcc/ada
parentca320dabf052c6fa53c25d77646e2edfffc18594 (diff)
[Ada] Misplace of internal master renaming declaration
gcc/ada/ * exp_ch3.adb (Expand_N_Full_Type_Declaration): Ensure a _master declaration on limited types that might have tasks. * exp_ch9.adb (Build_Master_Renaming): For private types, if we are processing declarations in the private part, ensure that master is inserted before its full declaration; otherwise the master renaming may be inserted in the public part of the package (and hence before the declaration of its _master variable).
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/exp_ch3.adb5
-rw-r--r--gcc/ada/exp_ch9.adb32
2 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index d90bbadd7c7..ba4f3da23bc 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -5898,7 +5898,10 @@ package body Exp_Ch3 is
Typ := Etype (Comp);
if Ekind (Typ) = E_Anonymous_Access_Type
- and then Has_Task (Available_View (Designated_Type (Typ)))
+ and then
+ (Has_Task (Available_View (Designated_Type (Typ)))
+ or else
+ Might_Have_Tasks (Available_View (Designated_Type (Typ))))
and then No (Master_Id (Typ))
then
-- Ensure that the record or array type have a _master
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index 001aa4b77d4..26de2c32b27 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -3576,8 +3576,40 @@ package body Exp_Ch9 is
if Present (Ins_Nod) then
Context := Ins_Nod;
+
elsif Is_Itype (Ptr_Typ) then
Context := Associated_Node_For_Itype (Ptr_Typ);
+
+ -- When the context references a discriminant or a component of a
+ -- private type and we are processing declarations in the private
+ -- part of the enclosing package, we must insert the master renaming
+ -- before the full declaration of the private type; otherwise the
+ -- master renaming would be inserted in the public part of the
+ -- package (and hence before the declaration of _master).
+
+ if In_Private_Part (Current_Scope) then
+ declare
+ Ctx : Node_Id := Context;
+
+ begin
+ if Nkind (Context) = N_Discriminant_Specification then
+ Ctx := Parent (Ctx);
+ else
+ while Nkind_In (Ctx, N_Component_Declaration,
+ N_Component_List)
+ loop
+ Ctx := Parent (Ctx);
+ end loop;
+ end if;
+
+ if Nkind_In (Ctx, N_Private_Type_Declaration,
+ N_Private_Extension_Declaration)
+ then
+ Context := Parent (Full_View (Defining_Identifier (Ctx)));
+ end if;
+ end;
+ end if;
+
else
Context := Parent (Ptr_Typ);
end if;