aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-12-16 09:08:49 +0100
committerTristan Gingold <tgingold@free.fr>2018-12-16 14:07:04 +0100
commitf4ca3078df0f565489458e898e5a0d3a673b04e2 (patch)
tree1cca3953e671b99df0dd876feca8944369c16416 /src
parent42e2e02a5f0d0e305561b44984a41391b04c157d (diff)
downloadghdl-f4ca3078df0f565489458e898e5a0d3a673b04e2.tar.gz
ghdl-f4ca3078df0f565489458e898e5a0d3a673b04e2.tar.bz2
ghdl-f4ca3078df0f565489458e898e5a0d3a673b04e2.zip
translate: handle unbounded aggregate as initial value.
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/translate/trans-chap4.adb34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb
index 7b8312290..c7c806b34 100644
--- a/src/vhdl/translate/trans-chap4.adb
+++ b/src/vhdl/translate/trans-chap4.adb
@@ -547,20 +547,34 @@ package body Trans.Chap4 is
-- Allocate.
declare
Aggr_Type : constant Iir := Get_Type (Value);
+ Aggr_Base_Type : constant Iir := Get_Base_Type (Aggr_Type);
begin
- Chap3.Create_Composite_Subtype (Aggr_Type);
Name_Node := Stabilize (Name);
- 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_Composite_Type_Bounds (Aggr_Type)));
+ if Get_Constraint_State (Aggr_Type) /= Fully_Constrained then
+ -- Allocate bounds
+ Chap3.Allocate_Unbounded_Composite_Bounds
+ (Alloc_Kind, Name_Node, Aggr_Base_Type);
+ -- Translate bounds
+ Chap7.Translate_Aggregate_Bounds
+ (Stabilize (Chap3.Get_Composite_Bounds (Name_Node)),
+ Value);
+ -- Allocate base
Chap3.Allocate_Unbounded_Composite_Base
- (Alloc_Kind, Name_Node, Get_Base_Type (Aggr_Type));
+ (Alloc_Kind, Name_Node, Aggr_Base_Type);
else
- Chap3.Translate_Object_Allocation
- (Name_Node, Alloc_Kind, Get_Base_Type (Aggr_Type),
- Chap3.Get_Composite_Type_Bounds (Aggr_Type));
+ Chap3.Create_Composite_Subtype (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_Composite_Type_Bounds (Aggr_Type)));
+ Chap3.Allocate_Unbounded_Composite_Base
+ (Alloc_Kind, Name_Node, Aggr_Base_Type);
+ else
+ Chap3.Translate_Object_Allocation
+ (Name_Node, Alloc_Kind, Aggr_Base_Type,
+ Chap3.Get_Composite_Type_Bounds (Aggr_Type));
+ end if;
end if;
end;
else