aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-07-22 03:26:13 +0200
committerTristan Gingold <tgingold@free.fr>2018-07-22 03:26:13 +0200
commitd3b9380ac7dcaf6bd90a7460f39db6b82568d705 (patch)
tree42116cd72d0534181a257e3160d405e40dbcd177
parent109536797e645dc50f568aa6813b1d6cd5f75edc (diff)
downloadghdl-d3b9380ac7dcaf6bd90a7460f39db6b82568d705.tar.gz
ghdl-d3b9380ac7dcaf6bd90a7460f39db6b82568d705.tar.bz2
ghdl-d3b9380ac7dcaf6bd90a7460f39db6b82568d705.zip
elab_object_init: allocate bounds for unounded aggregate if needed.
Fix #626
-rw-r--r--src/vhdl/translate/trans-chap4.adb17
1 files changed, 12 insertions, 5 deletions
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;