diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-03-23 19:02:48 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-03-23 19:02:48 +0100 |
commit | a133f0a51362d7b2134277458e26984c711e2fb2 (patch) | |
tree | 011c5e4357d40e60e38277d07c63d57fe563e6bc | |
parent | 24cbc598dd3200eb6842b68713eeec9369d186ab (diff) | |
download | ghdl-a133f0a51362d7b2134277458e26984c711e2fb2.tar.gz ghdl-a133f0a51362d7b2134277458e26984c711e2fb2.tar.bz2 ghdl-a133f0a51362d7b2134277458e26984c711e2fb2.zip |
synth: handle multiple constant declarations. Fix #1172
-rw-r--r-- | src/synth/synth-decls.adb | 27 | ||||
-rw-r--r-- | src/synth/synth-decls.ads | 6 | ||||
-rw-r--r-- | src/synth/synth-stmts.adb | 4 |
3 files changed, 25 insertions, 12 deletions
diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb index f83ec1bbd..63710b065 100644 --- a/src/synth/synth-decls.adb +++ b/src/synth/synth-decls.adb @@ -448,7 +448,7 @@ package body Synth.Decls is end Synth_Declaration_Type; procedure Synth_Constant_Declaration - (Syn_Inst : Synth_Instance_Acc; Decl : Node) + (Syn_Inst : Synth_Instance_Acc; Decl : Node; Last_Type : in out Node) is Deferred_Decl : constant Node := Get_Deferred_Declaration (Decl); First_Decl : Node; @@ -481,9 +481,14 @@ package body Synth.Decls is -- be derived from the value. -- FIXME: what about multiple declarations ? Decl_Type := Get_Subtype_Indication (Decl); - if Get_Kind (Decl_Type) in Iir_Kinds_Denoting_Name then - -- Type mark. - Decl_Type := Get_Type (Get_Named_Entity (Decl_Type)); + if Decl_Type = Null_Node then + Decl_Type := Last_Type; + else + if Get_Kind (Decl_Type) in Iir_Kinds_Denoting_Name then + -- Type mark. + Decl_Type := Get_Type (Get_Named_Entity (Decl_Type)); + end if; + Last_Type := Decl_Type; end if; Obj_Type := Get_Value_Type (Syn_Inst, Decl_Type); Val := Synth_Expression_With_Type @@ -723,8 +728,10 @@ package body Synth.Decls is end if; end Synth_Variable; - procedure Synth_Declaration - (Syn_Inst : Synth_Instance_Acc; Decl : Node; Is_Subprg : Boolean) is + procedure Synth_Declaration (Syn_Inst : Synth_Instance_Acc; + Decl : Node; + Is_Subprg : Boolean; + Last_Type : in out Node) is begin case Get_Kind (Decl) is when Iir_Kind_Variable_Declaration => @@ -734,7 +741,7 @@ package body Synth.Decls is Create_Wire_Object (Syn_Inst, Wire_Variable, Decl); Create_Var_Wire (Syn_Inst, Decl, null); when Iir_Kind_Constant_Declaration => - Synth_Constant_Declaration (Syn_Inst, Decl); + Synth_Constant_Declaration (Syn_Inst, Decl, Last_Type); when Iir_Kind_Signal_Declaration => Synth_Declaration_Type (Syn_Inst, Decl); declare @@ -839,11 +846,13 @@ package body Synth.Decls is procedure Synth_Declarations (Syn_Inst : Synth_Instance_Acc; Decls : Iir; Is_Subprg : Boolean := False) is - Decl : Iir; + Decl : Node; + Last_Type : Node; begin + Last_Type := Null_Node; Decl := Decls; while Is_Valid (Decl) loop - Synth_Declaration (Syn_Inst, Decl, Is_Subprg); + Synth_Declaration (Syn_Inst, Decl, Is_Subprg, Last_Type); Decl := Get_Chain (Decl); end loop; diff --git a/src/synth/synth-decls.ads b/src/synth/synth-decls.ads index 66e961cf6..5faa1bfa3 100644 --- a/src/synth/synth-decls.ads +++ b/src/synth/synth-decls.ads @@ -40,8 +40,10 @@ package Synth.Decls is procedure Synth_Declaration_Type (Syn_Inst : Synth_Instance_Acc; Decl : Node); - procedure Synth_Declaration - (Syn_Inst : Synth_Instance_Acc; Decl : Node; Is_Subprg : Boolean); + procedure Synth_Declaration (Syn_Inst : Synth_Instance_Acc; + Decl : Node; + Is_Subprg : Boolean; + Last_Type : in out Node); procedure Synth_Declarations (Syn_Inst : Synth_Instance_Acc; Decls : Iir; diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index 92010c413..fc7f70806 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -3238,6 +3238,7 @@ package body Synth.Stmts is Unit_Sname : Sname; M : Areapools.Mark_Type; Item : Node; + Last_Type : Node; begin Unit_Sname := New_Sname_User (Get_Identifier (Unit), Get_Sname (Syn_Inst)); @@ -3245,6 +3246,7 @@ package body Synth.Stmts is Mark (M, Proc_Pool); Instance_Pool := Proc_Pool'Access; + Last_Type := Null_Node; Item := Get_Vunit_Item_Chain (Unit); while Item /= Null_Node loop case Get_Kind (Item) is @@ -3265,7 +3267,7 @@ package body Synth.Stmts is | Iir_Kind_Procedure_Body | Iir_Kind_Attribute_Declaration | Iir_Kind_Attribute_Specification => - Synth_Declaration (Unit_Inst, Item, False); + Synth_Declaration (Unit_Inst, Item, False, Last_Type); when Iir_Kind_Concurrent_Simple_Signal_Assignment => Synth_Concurrent_Statement (Unit_Inst, Item); when others => |