+2016-10-12 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch12.adb (Check_Formal_Package_Instance): Skip an internal
+ formal entity without a parent only if the corresponding actual
+ entity has a different kind.
+ * exp_ch9.adb (Build_Class_Wide_Master): If the master is
+ declared locally, insert the renaming declaration after the
+ master declaration, to prevent access before elaboration in gigi.
+
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* contracts.adb (Analyze_Contracts): For a type declaration, analyze
procedure Build_Class_Wide_Master (Typ : Entity_Id) is
Loc : constant Source_Ptr := Sloc (Typ);
Master_Id : Entity_Id;
+ Master_Decl : Node_Id;
Master_Scope : Entity_Id;
Name_Id : Node_Id;
Related_Node : Node_Id;
-- the second transient scope requires a _master, it cannot use the one
-- already declared because the entity is not visible.
- Name_Id := Make_Identifier (Loc, Name_uMaster);
+ Name_Id := Make_Identifier (Loc, Name_uMaster);
+ Master_Decl := Empty;
if not Has_Master_Entity (Master_Scope)
or else No (Current_Entity_In_Scope (Name_Id))
then
- declare
- Master_Decl : Node_Id;
begin
Set_Has_Master_Entity (Master_Scope);
Subtype_Mark => New_Occurrence_Of (Standard_Integer, Loc),
Name => Name_Id);
- Insert_Action (Related_Node, Ren_Decl);
+ -- If the master is declared locally, add the renaming declaration
+ -- immediately after it, to prevent access-before-elaboration in the
+ -- back-end.
+
+ if Present (Master_Decl) then
+ Insert_After (Master_Decl, Ren_Decl);
+ Analyze (Ren_Decl);
+
+ else
+ Insert_Action (Related_Node, Ren_Decl);
+ end if;
Set_Master_Id (Typ, Master_Id);
end Build_Class_Wide_Master;
-- itypes and predefined operators (concatenation for arrays, eg).
-- Skip it and keep the formal entity to find a later match for it.
- elsif No (Parent (E2)) then
+ elsif No (Parent (E2)) and then Ekind (E1) /= Ekind (E2) then
E1 := Prev_E1;
goto Next_E;