From: Ed Schonberg Date: Wed, 12 Oct 2016 10:40:37 +0000 (+0000) Subject: sem_ch12.adb (Check_Formal_Package_Instance): Skip an internal formal entity without... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5b4c1029596a33d420738c3ef7bc547edd924321;p=gcc.git sem_ch12.adb (Check_Formal_Package_Instance): Skip an internal formal entity without a parent only if... 2016-10-12 Ed Schonberg * 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. From-SVN: r241029 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ad188a70e1b..87a5447d79a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2016-10-12 Ed Schonberg + + * 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 * contracts.adb (Analyze_Contracts): For a type declaration, analyze diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index 6c572cef3ea..22373ddaa57 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -1107,6 +1107,7 @@ package body Exp_Ch9 is 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; @@ -1146,13 +1147,12 @@ package body Exp_Ch9 is -- 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); @@ -1214,7 +1214,17 @@ package body Exp_Ch9 is 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; diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index efeaf4f661c..ed5e948377f 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -5989,7 +5989,7 @@ package body Sem_Ch12 is -- 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;