From bb072d1c1716ecb6cd99f43a5dbc4855931302d3 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 6 Jul 2016 14:40:07 +0200 Subject: [multiple changes] 2016-07-06 Hristian Kirtchev * exp_aggr.adb Remove with and use clauses for Exp_Ch11 and Inline. (Initialize_Array_Component): Protect the initialization statements in an abort defer / undefer block when the associated component is controlled. (Initialize_Record_Component): Protect the initialization statements in an abort defer / undefer block when the associated component is controlled. (Process_Transient_Component_Completion): Use Build_Abort_Undefer_Block to create an abort defer / undefer block. * exp_ch3.adb Remove with and use clauses for Exp_ch11 and Inline. (Default_Initialize_Object): Use Build_Abort_Undefer_Block to create an abort defer / undefer block. * exp_ch5.adb (Expand_N_Assignment_Statement): Mark an abort defer / undefer block as such. * exp_ch9.adb (Find_Enclosing_Context): Do not consider an abort defer / undefer block as a suitable context for an activation chain or a master. * exp_util.adb Add with and use clauses for Exp_Ch11. (Build_Abort_Undefer_Block): New routine. * exp_util.ads (Build_Abort_Undefer_Block): New routine. * sinfo.adb (Is_Abort_Block): New routine. (Set_Is_Abort_Block): New routine. * sinfo.ads New attribute Is_Abort_Block along with occurrences in nodes. (Is_Abort_Block): New routine along with pragma Inline. (Set_Is_Abort_Block): New routine along with pragma Inline. 2016-07-06 Justin Squirek * sem_ch4.adb (Analyze_One_Call): Add a conditional to handle disambiguation. From-SVN: r238045 --- gcc/ada/sem_ch4.adb | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'gcc/ada/sem_ch4.adb') diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 17c6308..5bbc1a3 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -3480,6 +3480,61 @@ package body Sem_Ch4 is Next_Actual (Actual); Next_Formal (Formal); + -- In a complex case where an enclosing generic and a nested + -- generic package, both declared with partially parameterized + -- formal subprograms with the same names, are instantiated + -- with the same type, the types of the actual parameter and + -- that of the formal may appear incompatible at first sight. + + -- generic + -- type Outer_T is private; + -- with function Func (Formal : Outer_T) + -- return ... is <>; + + -- package Outer_Gen is + -- generic + -- type Inner_T is private; + -- with function Func (Formal : Inner_T) -- (1) + -- return ... is <>; + + -- package Inner_Gen is + -- function Inner_Func (Formal : Inner_T) -- (2) + -- return ... is (Func (Formal)); + -- end Inner_Gen; + -- end Outer_Generic; + + -- package Outer_Inst is new Outer_Gen (Actual_T); + -- package Inner_Inst is new Outer_Inst.Inner_Gen (Actual_T); + + -- In the example above, the type of parameter + -- Inner_Func.Formal at (2) is incompatible with the type of + -- Func.Formal at (1) in the context of instantiations + -- Outer_Inst and Inner_Inst. In reality both types are + -- generic actual subtypes renaming base type Actual_T as + -- part of the generic prologues for the instantiations. + + -- Recognize this case and add a type conversion to allow + -- this kind of generic actual subtype conformance. Note that + -- this is done only when the call is non-overloaded because + -- the resolution mechanism already has the means to + -- disambiguate similar cases. + + elsif not Is_Overloaded (Name (N)) + and then Is_Type (Etype (Actual)) + and then Is_Type (Etype (Formal)) + and then Is_Generic_Actual_Type (Etype (Actual)) + and then Is_Generic_Actual_Type (Etype (Formal)) + and then Base_Type (Etype (Actual)) = + Base_Type (Etype (Formal)) + then + Rewrite (Actual, + Convert_To (Etype (Formal), Relocate_Node (Actual))); + Analyze_And_Resolve (Actual, Etype (Formal)); + Next_Actual (Actual); + Next_Formal (Formal); + + -- Handle failed type check + else if Debug_Flag_E then Write_Str (" type checking fails in call "); -- cgit v1.1