diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-11-20 17:23:32 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-11-20 17:23:32 +0100 |
commit | 1d566ee1a598f2c80b0928c9b29a799590d8822b (patch) | |
tree | cfb6cdc6fb2080c5a4877b4eb873a4490e0f3130 | |
parent | 8c63e8e316e9ab84931bc52eba002d56c14922a5 (diff) | |
download | ghdl-1d566ee1a598f2c80b0928c9b29a799590d8822b.tar.gz ghdl-1d566ee1a598f2c80b0928c9b29a799590d8822b.tar.bz2 ghdl-1d566ee1a598f2c80b0928c9b29a799590d8822b.zip |
Handle assignment of aggregate to an unbounded variable.
Fix #610
-rw-r--r-- | src/vhdl/translate/trans-chap8.adb | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb index d6dde2b23..490a104bc 100644 --- a/src/vhdl/translate/trans-chap8.adb +++ b/src/vhdl/translate/trans-chap8.adb @@ -988,12 +988,37 @@ package body Trans.Chap8 is else Targ_Node := Chap6.Translate_Name (Target, Mode_Value); if Get_Kind (Expr) = Iir_Kind_Aggregate then - declare - E : O_Enode; - begin - E := Chap7.Translate_Expression (Expr, Targ_Type); - Chap3.Translate_Object_Copy (Targ_Node, E, Targ_Type); - end; + if Get_Constraint_State (Get_Type (Expr)) /= Fully_Constrained then + declare + Expr_Type : constant Iir := Get_Type (Expr); + Expr_Tinfo : constant Type_Info_Acc := Get_Info (Expr_Type); + Val : Mnode; + begin + -- Create a temp. + Val := Create_Temp (Expr_Tinfo); + -- Set bounds from target + Stabilize (Targ_Node); + New_Assign_Stmt + (M2Lp (Chap3.Get_Composite_Bounds (Val)), + M2Addr (Chap3.Get_Composite_Bounds (Targ_Node))); + -- Allocate target + Chap3.Allocate_Unbounded_Composite_Base + (Alloc_Stack, Val, Get_Base_Type (Expr_Type)); + -- Translate aggregate + Chap7.Translate_Aggregate (Val, Targ_Type, Expr); + -- Assign + Chap3.Translate_Object_Copy + (Targ_Node, M2Addr (Val), Targ_Type); + end; + else + -- In case of overlap: be sure to use an intermediate variable. + declare + E : O_Enode; + begin + E := Chap7.Translate_Expression (Expr, Targ_Type); + Chap3.Translate_Object_Copy (Targ_Node, E, Targ_Type); + end; + end if; else Chap7.Translate_Assign (Targ_Node, Expr, Targ_Type); end if; |