diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2016-07-06 14:40:07 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2016-07-06 14:40:07 +0200 |
commit | bb072d1c1716ecb6cd99f43a5dbc4855931302d3 (patch) | |
tree | 620ce7d743d7bff057b8ab91942a5638a830c51b /gcc/ada/sem_ch4.adb | |
parent | 937e96763e42c48c29e3a5edf2eea3fb2c59fb27 (diff) | |
download | gcc-bb072d1c1716ecb6cd99f43a5dbc4855931302d3.zip gcc-bb072d1c1716ecb6cd99f43a5dbc4855931302d3.tar.gz gcc-bb072d1c1716ecb6cd99f43a5dbc4855931302d3.tar.bz2 |
[multiple changes]
2016-07-06 Hristian Kirtchev <kirtchev@adacore.com>
* 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 <squirek@adacore.com>
* sem_ch4.adb (Analyze_One_Call): Add a conditional to handle
disambiguation.
From-SVN: r238045
Diffstat (limited to 'gcc/ada/sem_ch4.adb')
-rw-r--r-- | gcc/ada/sem_ch4.adb | 55 |
1 files changed, 55 insertions, 0 deletions
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 "); |