diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-02-18 08:58:12 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-02-18 08:58:12 +0100 |
commit | 74663a2498f9c596e831502ae7c1d56bc51fbebf (patch) | |
tree | bb971f11346c663c09ffab7bcd6676c936da45ae /src/vhdl | |
parent | 047a8c2a033ac21ac17b5d05584795f83cfcd776 (diff) | |
download | ghdl-74663a2498f9c596e831502ae7c1d56bc51fbebf.tar.gz ghdl-74663a2498f9c596e831502ae7c1d56bc51fbebf.tar.bz2 ghdl-74663a2498f9c596e831502ae7c1d56bc51fbebf.zip |
translate: handle anonymous types in formal; handle multiple conversions.
Fix #530
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/translate/trans-chap4.adb | 12 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap9.adb | 30 |
2 files changed, 31 insertions, 11 deletions
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb index 444d4ae68..977afc4eb 100644 --- a/src/vhdl/translate/trans-chap4.adb +++ b/src/vhdl/translate/trans-chap4.adb @@ -2630,6 +2630,7 @@ package body Trans.Chap4 is Inter : Iir; Mode : Conv_Mode; Conv_Info : in out Assoc_Conv_Info; + Num : Iir_Int32; Base_Block : Iir; Entity : Iir) is @@ -2678,7 +2679,8 @@ package body Trans.Chap4 is end case; -- FIXME: individual assoc -> overload. Push_Identifier_Prefix - (Mark3, Get_Identifier (Get_Association_Interface (Assoc, Inter))); + (Mark3, Get_Identifier (Get_Association_Interface (Assoc, Inter)), + Num); -- Handle anonymous subtypes. Chap3.Translate_Anonymous_Subtype_Definition (Out_Type, False); @@ -2942,8 +2944,10 @@ package body Trans.Chap4 is Assoc : Iir; Inter : Iir; Info : Assoc_Info_Acc; + Num : Iir_Int32; begin Assoc := Get_Port_Map_Aspect_Chain (Stmt); + Num := 0; if Is_Null (Entity) then Inter := Get_Port_Chain (Stmt); else @@ -2957,7 +2961,8 @@ package body Trans.Chap4 is Info := Add_Info (Assoc, Kind_Assoc); Translate_Association_Subprogram (Stmt, Block, Assoc, Inter, Conv_Mode_In, Info.Assoc_In, - Base_Block, Entity); + Num, Base_Block, Entity); + Num := Num + 1; end if; if Get_Formal_Conversion (Assoc) /= Null_Iir then if Info = null then @@ -2965,7 +2970,8 @@ package body Trans.Chap4 is end if; Translate_Association_Subprogram (Stmt, Block, Assoc, Inter, Conv_Mode_Out, Info.Assoc_Out, - Base_Block, Entity); + Num, Base_Block, Entity); + Num := Num + 1; end if; end if; Next_Association_Interface (Assoc, Inter); diff --git a/src/vhdl/translate/trans-chap9.adb b/src/vhdl/translate/trans-chap9.adb index 43cef0f1c..35585d315 100644 --- a/src/vhdl/translate/trans-chap9.adb +++ b/src/vhdl/translate/trans-chap9.adb @@ -165,10 +165,12 @@ package body Trans.Chap9 is Mark, Mark2 : Id_Mark_Type; Assoc, Inter : Iir; + Num : Iir_Int32; Has_Conv_Record : Boolean := False; begin Info := Add_Info (Inst, Kind_Block); Push_Identifier_Prefix (Mark, Get_Label (Inst)); + Num := 0; if Is_Component_Instantiation (Inst) then -- Via a component declaration. @@ -191,7 +193,7 @@ package body Trans.Chap9 is end if; -- When conversions are used, the subtype of the actual (or of the - -- formal for out conversions) may not be yet translated. This + -- formal for formal conversions) may not be yet translated. This -- can happen if the name is a slice. -- We need to translate it and create variables in the instance -- because it will be referenced by the conversion subprogram. @@ -201,12 +203,16 @@ package body Trans.Chap9 is if Get_Kind (Assoc) = Iir_Kind_Association_Element_By_Expression then declare - Conv : constant Iir := Get_Actual_Conversion (Assoc); - In_Type : constant Iir := Get_Type (Get_Actual (Assoc)); + Act_Conv : constant Iir := Get_Actual_Conversion (Assoc); + Act_Type : constant Iir := Get_Type (Get_Actual (Assoc)); + Form_Conv : constant Iir := Get_Formal_Conversion (Assoc); + Formal : constant Iir := Get_Formal (Assoc); + Need_Actual : constant Boolean := Act_Conv /= Null_Iir + and then Is_Anonymous_Type_Definition (Act_Type); + Need_Formal : constant Boolean := Form_Conv /= Null_Iir + and then Is_Anonymous_Type_Definition (Get_Type (Formal)); begin - if Conv /= Null_Iir - and then Is_Anonymous_Type_Definition (In_Type) - then + if Need_Actual or Need_Formal then -- Lazy creation of the record. if not Has_Conv_Record then Has_Conv_Record := True; @@ -218,8 +224,16 @@ package body Trans.Chap9 is Push_Identifier_Prefix (Mark2, Get_Identifier - (Get_Association_Interface (Assoc, Inter))); - Chap3.Translate_Anonymous_Subtype_Definition (In_Type, True); + (Get_Association_Interface (Assoc, Inter)), Num); + Num := Num + 1; + if Need_Actual then + Chap3.Translate_Anonymous_Subtype_Definition + (Act_Type, True); + end if; + if Need_Formal then + Chap3.Translate_Anonymous_Subtype_Definition + (Get_Type (Formal), True); + end if; Pop_Identifier_Prefix (Mark2); end if; end; |