From d3b9380ac7dcaf6bd90a7460f39db6b82568d705 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 22 Jul 2018 03:26:13 +0200 Subject: elab_object_init: allocate bounds for unounded aggregate if needed. Fix #626 --- src/vhdl/translate/trans-chap4.adb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb index 977afc4eb..f32ec0f91 100644 --- a/src/vhdl/translate/trans-chap4.adb +++ b/src/vhdl/translate/trans-chap4.adb @@ -531,11 +531,18 @@ package body Trans.Chap4 is begin Chap3.Create_Array_Subtype (Aggr_Type); Name_Node := Stabilize (Name); - New_Assign_Stmt - (M2Lp (Chap3.Get_Composite_Bounds (Name_Node)), - M2Addr (Chap3.Get_Array_Type_Bounds (Aggr_Type))); - Chap3.Allocate_Unbounded_Composite_Base - (Alloc_Kind, Name_Node, Get_Base_Type (Aggr_Type)); + if Alloc_Kind = Alloc_Stack then + -- Short-cut: don't allocate bounds. + New_Assign_Stmt + (M2Lp (Chap3.Get_Composite_Bounds (Name_Node)), + M2Addr (Chap3.Get_Array_Type_Bounds (Aggr_Type))); + Chap3.Allocate_Unbounded_Composite_Base + (Alloc_Kind, Name_Node, Get_Base_Type (Aggr_Type)); + else + Chap3.Translate_Object_Allocation + (Name_Node, Alloc_Kind, Get_Base_Type (Aggr_Type), + Chap3.Get_Array_Type_Bounds (Aggr_Type)); + end if; end; else Name_Node := Name; -- cgit v1.2.3