aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-01-17 06:34:47 +0100
committerTristan Gingold <tgingold@free.fr>2018-01-17 06:34:47 +0100
commit6487c7008b36ed7a94a59b3b02bb7e7b28fe4ac8 (patch)
treea6fa300d314644069585852959c571345b9b7491 /src
parent4d52610e330ab24aea76eaae8295fd7771beedda (diff)
downloadghdl-6487c7008b36ed7a94a59b3b02bb7e7b28fe4ac8.tar.gz
ghdl-6487c7008b36ed7a94a59b3b02bb7e7b28fe4ac8.tar.bz2
ghdl-6487c7008b36ed7a94a59b3b02bb7e7b28fe4ac8.zip
Translate; properly separates translation of types from translation of subtypes.
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/translate/trans-chap3.adb212
-rw-r--r--src/vhdl/translate/trans-chap3.ads19
-rw-r--r--src/vhdl/translate/trans-chap4.adb38
-rw-r--r--src/vhdl/translate/trans-chap5.adb3
-rw-r--r--src/vhdl/translate/trans-chap7.adb13
-rw-r--r--src/vhdl/translate/trans-chap8.adb6
-rw-r--r--src/vhdl/translate/trans-chap9.adb42
7 files changed, 219 insertions, 114 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb
index 3dcc564bb..75304d669 100644
--- a/src/vhdl/translate/trans-chap3.adb
+++ b/src/vhdl/translate/trans-chap3.adb
@@ -1153,7 +1153,7 @@ package body Trans.Chap3 is
El_Type := Get_Type (El);
if Get_Info (El_Type) = null then
Push_Identifier_Prefix (Mark, Get_Identifier (El));
- Translate_Type_Definition (El_Type);
+ Translate_Subtype_Indication (El_Type, True);
Pop_Identifier_Prefix (Mark);
end if;
Need_Size := Need_Size or else Is_Complex_Type (Get_Info (El_Type));
@@ -1257,7 +1257,7 @@ package body Trans.Chap3 is
Has_Boxed_Elements := True;
end if;
Push_Identifier_Prefix (Mark, Get_Identifier (El));
- Translate_Type_Definition (El_Type);
+ Translate_Subtype_Definition (El_Type, El_Btype, With_Vars);
Pop_Identifier_Prefix (Mark);
end if;
end if;
@@ -2279,17 +2279,15 @@ package body Trans.Chap3 is
begin
if Get_Info (El_Type) = null then
Push_Identifier_Prefix (Mark, "ET");
- Translate_Type_Definition (El_Type);
+ Translate_Subtype_Indication (El_Type, True);
Pop_Identifier_Prefix (Mark);
end if;
end Translate_Array_Element_Definition;
-- Note: boolean types are translated by translate_bool_type_definition!
- procedure Translate_Type_Definition (Def : Iir; With_Vars : Boolean := True)
+ procedure Translate_Type_Definition (Def : Iir)
is
Info : Ortho_Info_Acc;
- Base_Info : Type_Info_Acc;
- Base_Type : Iir;
Complete_Info : Incomplete_Type_Info_Acc;
begin
-- Handle the special case of incomplete type.
@@ -2318,9 +2316,6 @@ package body Trans.Chap3 is
Info := Add_Info (Def, Kind_Type);
- Base_Type := Get_Base_Type (Def);
- Base_Info := Get_Info (Base_Type);
-
case Get_Kind (Def) is
when Iir_Kind_Enumeration_Type_Definition =>
Translate_Enumeration_Type (Def);
@@ -2334,7 +2329,7 @@ package body Trans.Chap3 is
when Iir_Kind_Physical_Type_Definition =>
Translate_Physical_Type (Def);
Create_Scalar_Type_Range_Type (Def, False);
- if With_Vars and Get_Type_Staticness (Def) /= Locally then
+ if Get_Type_Staticness (Def) /= Locally then
Translate_Physical_Units (Def);
else
Info.S.Range_Var := Null_Var;
@@ -2344,71 +2339,24 @@ package body Trans.Chap3 is
Translate_Floating_Type (Def);
Create_Scalar_Type_Range_Type (Def, False);
- when Iir_Kinds_Scalar_Subtype_Definition =>
- declare
- Tm : constant Iir := Get_Denoted_Type_Mark (Def);
- begin
- if Is_Valid (Tm) then
- Create_Subtype_Info_From_Type (Def, Tm, Info);
- else
- Create_Subtype_Info_From_Type (Def, Base_Type, Info);
- end if;
- if With_Vars and then not Info.S.Same_Range then
- Create_Type_Range_Var (Def);
- end if;
- end;
-
when Iir_Kind_Array_Type_Definition =>
Translate_Array_Element_Definition (Def);
Translate_Array_Type_Definition (Def);
- when Iir_Kind_Array_Subtype_Definition =>
- Translate_Array_Element_Definition (Def);
- if Base_Info = null or else Base_Info.Type_Incomplete then
- -- This subtype also declare the base type. Create it.
- declare
- Mark : Id_Mark_Type;
- begin
- Push_Identifier_Prefix (Mark, "BT");
- Translate_Type_Definition (Base_Type);
- Pop_Identifier_Prefix (Mark);
- Base_Info := Get_Info (Base_Type);
- end;
- end if;
-
- if Get_Constraint_State (Def) = Fully_Constrained then
- Translate_Array_Subtype_Definition (Def);
- Info.B := Base_Info.B;
- Info.S := Base_Info.S;
- if With_Vars then
- Create_Composite_Subtype_Bounds_Var (Def, False);
- end if;
- else
- -- An unconstrained array subtype. Use same infos as base
- -- type.
- Free_Info (Def);
- Set_Info (Def, Base_Info);
- end if;
-
when Iir_Kind_Record_Type_Definition =>
Info.B := Ortho_Info_Basetype_Record_Init;
Translate_Record_Type (Def);
- when Iir_Kind_Record_Subtype_Definition =>
- Translate_Record_Subtype (Def, With_Vars);
-
- when Iir_Kind_Access_Subtype_Definition =>
- -- Like the access type.
- Free_Info (Def);
- Set_Info (Def, Base_Info);
-
when Iir_Kind_Access_Type_Definition =>
declare
Dtype : constant Iir := Get_Designated_Type (Def);
+ Mark : Id_Mark_Type;
begin
-- Translate the subtype
if Is_Anonymous_Type_Definition (Dtype) then
- Translate_Type_Definition (Dtype);
+ Push_Identifier_Prefix (Mark, "AT");
+ Translate_Subtype_Indication (Dtype, True);
+ Pop_Identifier_Prefix (Mark);
end if;
Translate_Access_Type (Def);
end;
@@ -2416,9 +2364,7 @@ package body Trans.Chap3 is
when Iir_Kind_File_Type_Definition =>
Info.B := Ortho_Info_Basetype_File_Init;
Translate_File_Type (Def);
- if With_Vars then
- Create_File_Type_Var (Def);
- end if;
+ Create_File_Type_Var (Def);
when Iir_Kind_Protected_Type_Declaration =>
Info.B := Ortho_Info_Basetype_Prot_Init;
@@ -2453,6 +2399,103 @@ package body Trans.Chap3 is
Create_Scalar_Type_Range_Type (Def, True);
end Translate_Bool_Type_Definition;
+ procedure Translate_Subtype_Definition
+ (Def : Iir; Parent_Type : Iir; With_Vars : Boolean := True)
+ is
+ Info : Ortho_Info_Acc;
+ Base_Info : Type_Info_Acc;
+ Base_Type : Iir;
+ Complete_Info : Incomplete_Type_Info_Acc;
+ begin
+ -- If the definition is already translated, return now.
+ Info := Get_Info (Def);
+ if Info /= null then
+ case Info.Kind is
+ when Kind_Type =>
+ -- The subtype was already translated.
+ return;
+ when Kind_Incomplete_Type =>
+ -- Type is being completed.
+ Complete_Info := Info;
+ Clear_Info (Def);
+ when others =>
+ raise Internal_Error;
+ end case;
+ else
+ Complete_Info := null;
+ end if;
+
+ Info := Add_Info (Def, Kind_Type);
+
+ Base_Type := Get_Base_Type (Def);
+ Base_Info := Get_Info (Base_Type);
+
+ case Get_Kind (Def) is
+ when Iir_Kinds_Scalar_Subtype_Definition =>
+ Create_Subtype_Info_From_Type (Def, Parent_Type, Info);
+ if With_Vars and then not Info.S.Same_Range then
+ Create_Type_Range_Var (Def);
+ end if;
+
+ when Iir_Kind_Array_Subtype_Definition =>
+ declare
+ El_Type : constant Iir := Get_Element_Subtype (Def);
+ Parent_El_Type : constant Iir :=
+ Get_Element_Subtype (Parent_Type);
+ Mark : Id_Mark_Type;
+ begin
+ if El_Type /= Parent_El_Type then
+ Push_Identifier_Prefix (Mark, "ET");
+ Translate_Subtype_Definition
+ (El_Type, Parent_El_Type, With_Vars);
+ Pop_Identifier_Prefix (Mark);
+ end if;
+ end;
+
+ if Base_Info = null or else Base_Info.Type_Incomplete then
+ -- This subtype also declare the base type. Create it.
+ declare
+ Mark : Id_Mark_Type;
+ begin
+ Push_Identifier_Prefix (Mark, "BT");
+ Translate_Type_Definition (Base_Type);
+ Pop_Identifier_Prefix (Mark);
+ Base_Info := Get_Info (Base_Type);
+ end;
+ raise Internal_Error;
+ end if;
+
+ if Get_Constraint_State (Def) = Fully_Constrained then
+ Translate_Array_Subtype_Definition (Def);
+ Info.B := Base_Info.B;
+ Info.S := Base_Info.S;
+ if With_Vars then
+ Create_Composite_Subtype_Bounds_Var (Def, False);
+ end if;
+ else
+ -- An unconstrained array subtype. Use same infos as base
+ -- type.
+ Free_Info (Def);
+ Set_Info (Def, Base_Info);
+ end if;
+
+ when Iir_Kind_Record_Subtype_Definition =>
+ Translate_Record_Subtype (Def, With_Vars);
+
+ when Iir_Kind_Access_Subtype_Definition =>
+ -- Like the access type.
+ Free_Info (Def);
+ Set_Info (Def, Base_Info);
+
+ when others =>
+ Error_Kind ("translate_subtype_definition", Def);
+ end case;
+
+ if Complete_Info /= null then
+ Translate_Complete_Type (Complete_Info);
+ end if;
+ end Translate_Subtype_Definition;
+
procedure Translate_Type_Subprograms
(Decl : Iir; Kind : Subprg_Translate_Kind)
is
@@ -2558,16 +2601,27 @@ package body Trans.Chap3 is
Create_Type_Definition_Size_Var (Def);
end Elab_Type_Definition;
- procedure Translate_Named_Type_Definition (Def : Iir; Id : Name_Id)
+ procedure Translate_Subtype_Indication (Def : Iir; With_Vars : Boolean)
+ is
+ Parent_Type : Iir;
+ begin
+ Parent_Type := Get_Subtype_Type_Mark (Def);
+ pragma Assert (Parent_Type /= Null_Iir);
+ Parent_Type := Get_Type (Get_Named_Entity (Parent_Type));
+ Translate_Subtype_Definition (Def, Parent_Type, With_Vars);
+ end Translate_Subtype_Indication;
+
+ procedure Translate_Named_Subtype_Definition (Def : Iir; Id : Name_Id)
is
Mark : Id_Mark_Type;
begin
Push_Identifier_Prefix (Mark, Id);
- Chap3.Translate_Type_Definition (Def);
+ Chap3.Translate_Subtype_Indication (Def, True);
Pop_Identifier_Prefix (Mark);
- end Translate_Named_Type_Definition;
+ end Translate_Named_Subtype_Definition;
- procedure Translate_Anonymous_Type_Definition (Def : Iir)
+ procedure Translate_Anonymous_Subtype_Definition
+ (Def : Iir; With_Vars : Boolean)
is
Type_Info : constant Type_Info_Acc := Get_Info (Def);
Mark : Id_Mark_Type;
@@ -2576,21 +2630,34 @@ package body Trans.Chap3 is
return;
end if;
Push_Identifier_Prefix_Uniq (Mark);
- Chap3.Translate_Type_Definition (Def, False);
+ Chap3.Translate_Subtype_Definition
+ (Def, Get_Base_Type (Def), With_Vars);
Pop_Identifier_Prefix (Mark);
- end Translate_Anonymous_Type_Definition;
+ end Translate_Anonymous_Subtype_Definition;
procedure Translate_Object_Subtype (Decl : Iir;
With_Vars : Boolean := True)
is
Def : constant Iir := Get_Type (Decl);
+ Parent_Type : Iir;
Mark : Id_Mark_Type;
Mark2 : Id_Mark_Type;
begin
if Is_Anonymous_Type_Definition (Def) then
Push_Identifier_Prefix (Mark, Get_Identifier (Decl));
Push_Identifier_Prefix (Mark2, "OT");
- Chap3.Translate_Type_Definition (Def, With_Vars);
+ Parent_Type := Get_Subtype_Type_Mark (Def);
+ if Parent_Type /= Null_Iir then
+ Parent_Type := Get_Type (Get_Named_Entity (Parent_Type));
+ else
+ Parent_Type := Get_Base_Type (Def);
+ -- Parent_Type should be integer_type_definition for iterators,
+ -- or the subtype indication for constant (in the case the
+ -- default value constrains the subtype indication), or an
+ -- object alias, or anywhere because of 'Subtype applied on one
+ -- of the above object...
+ end if;
+ Chap3.Translate_Subtype_Definition (Def, Parent_Type, With_Vars);
Pop_Identifier_Prefix (Mark2);
Pop_Identifier_Prefix (Mark);
end if;
@@ -3106,7 +3173,8 @@ package body Trans.Chap3 is
Push_Identifier_Prefix_Uniq (Mark);
if Get_Info (Sub_Type) = null then
-- Minimal subtype creation.
- Translate_Type_Definition (Sub_Type, False);
+ Translate_Subtype_Definition
+ (Sub_Type, Get_Base_Type (Sub_Type), False);
end if;
-- Force creation of variables.
Chap3.Create_Composite_Subtype_Bounds_Var (Sub_Type, True);
diff --git a/src/vhdl/translate/trans-chap3.ads b/src/vhdl/translate/trans-chap3.ads
index ec77c1d52..88a169f2a 100644
--- a/src/vhdl/translate/trans-chap3.ads
+++ b/src/vhdl/translate/trans-chap3.ads
@@ -37,11 +37,7 @@ package Trans.Chap3 is
-- 4. Create bounds constructor
-- 5. Create type descriptor declaration
-- 6. Create type descriptor constructor
- procedure Translate_Type_Definition
- (Def : Iir; With_Vars : Boolean := True);
-
- procedure Translate_Named_Type_Definition (Def : Iir; Id : Name_Id);
- procedure Translate_Anonymous_Type_Definition (Def : Iir);
+ procedure Translate_Type_Definition (Def : Iir);
-- Translate subprograms for types.
procedure Translate_Type_Subprograms
@@ -61,6 +57,19 @@ package Trans.Chap3 is
procedure Translate_Protected_Type_Body_Subprograms_Spec (Bod : Iir);
procedure Translate_Protected_Type_Body_Subprograms_Body (Bod : Iir);
+ procedure Translate_Subtype_Definition
+ (Def : Iir; Parent_Type : Iir; With_Vars : Boolean := True);
+
+ -- Translate a proper subtype indication.
+ procedure Translate_Subtype_Indication (Def : Iir; With_Vars : Boolean);
+
+ procedure Translate_Named_Subtype_Definition (Def : Iir; Id : Name_Id);
+
+ -- When there is no name for the subtype (eg: the subtype of a string or
+ -- of an aggregate). There is also no type mark.
+ procedure Translate_Anonymous_Subtype_Definition
+ (Def : Iir; With_Vars : Boolean);
+
-- Translate_type_definition_Elab do 4 and 6.
-- It generates code to do type elaboration.
procedure Elab_Type_Declaration (Decl : Iir);
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb
index 612dd24aa..444d4ae68 100644
--- a/src/vhdl/translate/trans-chap4.adb
+++ b/src/vhdl/translate/trans-chap4.adb
@@ -1470,10 +1470,20 @@ package body Trans.Chap4 is
Close_Temp;
end Final_File_Declaration;
- procedure Translate_Type_Declaration (Decl : Iir) is
+ procedure Translate_Type_Declaration (Decl : Iir)
+ is
+ Def : constant Iir := Get_Type_Definition (Decl);
+ Mark : Id_Mark_Type;
begin
- Chap3.Translate_Named_Type_Definition (Get_Type_Definition (Decl),
- Get_Identifier (Decl));
+ Push_Identifier_Prefix (Mark, Get_Identifier (Decl));
+ case Get_Kind (Def) is
+ when Iir_Kinds_Subtype_Definition =>
+ Chap3.Translate_Subtype_Indication (Def, True);
+ raise Internal_Error;
+ when others =>
+ Chap3.Translate_Type_Definition (Def);
+ end case;
+ Pop_Identifier_Prefix (Mark);
end Translate_Type_Declaration;
procedure Translate_Anonymous_Type_Declaration (Decl : Iir)
@@ -1490,9 +1500,21 @@ package body Trans.Chap4 is
procedure Translate_Subtype_Declaration (Decl : Iir_Subtype_Declaration)
is
+ Def : constant Iir := Get_Type (Decl);
+ Mark : Id_Mark_Type;
+ Parent_Type : Iir;
begin
- Chap3.Translate_Named_Type_Definition (Get_Type (Decl),
- Get_Identifier (Decl));
+ Push_Identifier_Prefix (Mark, Get_Identifier (Decl));
+ Parent_Type := Get_Subtype_Type_Mark (Def);
+ if Parent_Type /= Null_Iir then
+ -- For normal user subtype declaration.
+ Parent_Type := Get_Type (Get_Named_Entity (Parent_Type));
+ else
+ -- For implicit subtype declaration of a type declaration.
+ Parent_Type := Get_Base_Type (Def);
+ end if;
+ Chap3.Translate_Subtype_Definition (Def, Parent_Type, True);
+ Pop_Identifier_Prefix (Mark);
end Translate_Subtype_Declaration;
procedure Translate_Bool_Type_Declaration (Decl : Iir_Type_Declaration)
@@ -1513,7 +1535,7 @@ package body Trans.Chap4 is
Atype : O_Tnode;
Id : Var_Ident_Type;
begin
- Chap3.Translate_Named_Type_Definition (Decl_Type, Get_Identifier (Decl));
+ Chap3.Translate_Object_Subtype (Decl, True);
Info := Add_Info (Decl, Kind_Alias);
if Is_Signal_Name (Decl) then
@@ -2659,8 +2681,8 @@ package body Trans.Chap4 is
(Mark3, Get_Identifier (Get_Association_Interface (Assoc, Inter)));
-- Handle anonymous subtypes.
- Chap3.Translate_Anonymous_Type_Definition (Out_Type);
- Chap3.Translate_Anonymous_Type_Definition (In_Type);
+ Chap3.Translate_Anonymous_Subtype_Definition (Out_Type, False);
+ Chap3.Translate_Anonymous_Subtype_Definition (In_Type, False);
Out_Info := Get_Info (Out_Type);
In_Info := Get_Info (In_Type);
diff --git a/src/vhdl/translate/trans-chap5.adb b/src/vhdl/translate/trans-chap5.adb
index d02d60528..d140a4ed0 100644
--- a/src/vhdl/translate/trans-chap5.adb
+++ b/src/vhdl/translate/trans-chap5.adb
@@ -71,7 +71,8 @@ package body Trans.Chap5 is
Push_Identifier_Prefix_Uniq (Mark);
if Is_Anonymous_Type_Definition (Spec_Type) then
Push_Identifier_Prefix (Mark2, "OT");
- Chap3.Translate_Type_Definition (Spec_Type, True);
+ Chap3.Translate_Subtype_Definition
+ (Spec_Type, Get_Type (Attr), True);
Pop_Identifier_Prefix (Mark2);
end if;
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb
index 88bd45a9b..79b013f9a 100644
--- a/src/vhdl/translate/trans-chap7.adb
+++ b/src/vhdl/translate/trans-chap7.adb
@@ -240,7 +240,7 @@ package body Trans.Chap7 is
List : O_Array_Aggr_List;
Res : O_Cnode;
begin
- Chap3.Translate_Anonymous_Type_Definition (Aggr_Type);
+ Chap3.Translate_Anonymous_Subtype_Definition (Aggr_Type, False);
Start_Array_Aggr (List, Get_Ortho_Type (Aggr_Type, Mode_Value));
Translate_Static_Array_Aggregate_1 (List, Aggr, Aggr_Type, 1);
@@ -257,7 +257,7 @@ package body Trans.Chap7 is
List : O_Array_Aggr_List;
Res : O_Cnode;
begin
- Chap3.Translate_Anonymous_Type_Definition (Aggr_Type);
+ Chap3.Translate_Anonymous_Subtype_Definition (Aggr_Type, False);
Start_Array_Aggr (List, Get_Ortho_Type (Aggr_Type, Mode_Value));
for I in Flist_First .. Flist_Last (El_List) loop
@@ -280,7 +280,7 @@ package body Trans.Chap7 is
List : O_Array_Aggr_List;
Res : O_Cnode;
begin
- Chap3.Translate_Anonymous_Type_Definition (Lit_Type);
+ Chap3.Translate_Anonymous_Subtype_Definition (Lit_Type, False);
Arr_Type := Get_Ortho_Type (Lit_Type, Mode_Value);
Start_Array_Aggr (List, Arr_Type);
@@ -427,7 +427,7 @@ package body Trans.Chap7 is
List : O_Array_Aggr_List;
Res : O_Cnode;
begin
- Chap3.Translate_Anonymous_Type_Definition (Str_Type);
+ Chap3.Translate_Anonymous_Subtype_Definition (Str_Type, False);
Start_Array_Aggr (List, Get_Ortho_Type (Str_Type, Mode_Value));
@@ -3267,7 +3267,8 @@ package body Trans.Chap7 is
A_Range : Mnode;
begin
-- Evaluate the range.
- Chap3.Translate_Anonymous_Type_Definition (Subaggr_Type);
+ Chap3.Translate_Anonymous_Subtype_Definition
+ (Subaggr_Type, False);
A_Range :=
Dv2M (Create_Temp (Rinfo.B.Range_Type), Rinfo, Mode_Value,
@@ -3374,7 +3375,7 @@ package body Trans.Chap7 is
-- FIXME: creating aggregate subtype is expensive and rarely used.
-- (one of the current use - only ? - is check_array_match).
- Chap3.Translate_Anonymous_Type_Definition (Aggr_Type);
+ Chap3.Translate_Anonymous_Subtype_Definition (Aggr_Type, False);
end Translate_Array_Aggregate;
procedure Translate_Aggregate
diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb
index c78e270a0..f1f1b3839 100644
--- a/src/vhdl/translate/trans-chap8.adb
+++ b/src/vhdl/translate/trans-chap8.adb
@@ -973,7 +973,7 @@ package body Trans.Chap8 is
E : O_Enode;
Temp : Mnode;
begin
- Chap3.Translate_Anonymous_Type_Definition (Targ_Type);
+ Chap3.Translate_Anonymous_Subtype_Definition (Targ_Type, False);
-- Use a temporary variable, to avoid overlap.
Temp := Create_Temp (Get_Info (Targ_Type));
@@ -2767,7 +2767,7 @@ package body Trans.Chap8 is
-- For individual associations, be sure the type is translated.
-- That's required for slices in case of array conversion.
if Formal /= Base_Formal then
- Chap3.Translate_Anonymous_Type_Definition (Formal_Type);
+ Chap3.Translate_Anonymous_Subtype_Definition (Formal_Type, False);
end if;
-- Evaluate the actual.
@@ -4187,7 +4187,7 @@ package body Trans.Chap8 is
Target_Type : constant Iir := Get_Type (Target);
begin
if Get_Kind (Target) = Iir_Kind_Aggregate then
- Chap3.Translate_Anonymous_Type_Definition (Target_Type);
+ Chap3.Translate_Anonymous_Subtype_Definition (Target_Type, False);
Targ := Create_Temp (Get_Info (Target_Type), Mode_Signal);
Chap4.Allocate_Complex_Object (Target_Type, Alloc_Stack, Targ);
Translate_Signal_Target_Aggr (Targ, Target, Target_Type);
diff --git a/src/vhdl/translate/trans-chap9.adb b/src/vhdl/translate/trans-chap9.adb
index 4c6904fea..43cef0f1c 100644
--- a/src/vhdl/translate/trans-chap9.adb
+++ b/src/vhdl/translate/trans-chap9.adb
@@ -164,7 +164,7 @@ package body Trans.Chap9 is
Ports : Iir;
Mark, Mark2 : Id_Mark_Type;
- Assoc, Inter, Conv, In_Type : Iir;
+ Assoc, Inter : Iir;
Has_Conv_Record : Boolean := False;
begin
Info := Add_Info (Inst, Kind_Block);
@@ -200,25 +200,29 @@ package body Trans.Chap9 is
while Assoc /= Null_Iir loop
if Get_Kind (Assoc) = Iir_Kind_Association_Element_By_Expression
then
- Conv := Get_Actual_Conversion (Assoc);
- In_Type := Get_Type (Get_Actual (Assoc));
- if Conv /= Null_Iir
- and then Is_Anonymous_Type_Definition (In_Type)
- then
- -- Lazy creation of the record.
- if not Has_Conv_Record then
- Has_Conv_Record := True;
- Push_Instance_Factory (Info.Block_Scope'Access);
- end if;
+ declare
+ Conv : constant Iir := Get_Actual_Conversion (Assoc);
+ In_Type : constant Iir := Get_Type (Get_Actual (Assoc));
+ begin
+ if Conv /= Null_Iir
+ and then Is_Anonymous_Type_Definition (In_Type)
+ then
+ -- Lazy creation of the record.
+ if not Has_Conv_Record then
+ Has_Conv_Record := True;
+ Push_Instance_Factory (Info.Block_Scope'Access);
+ end if;
- -- FIXME: handle with overload multiple case on the same
- -- formal.
- Push_Identifier_Prefix
- (Mark2,
- Get_Identifier (Get_Association_Interface (Assoc, Inter)));
- Chap3.Translate_Type_Definition (In_Type, True);
- Pop_Identifier_Prefix (Mark2);
- end if;
+ -- FIXME: handle with overload multiple case on the same
+ -- formal.
+ Push_Identifier_Prefix
+ (Mark2,
+ Get_Identifier
+ (Get_Association_Interface (Assoc, Inter)));
+ Chap3.Translate_Anonymous_Subtype_Definition (In_Type, True);
+ Pop_Identifier_Prefix (Mark2);
+ end if;
+ end;
end if;
Next_Association_Interface (Assoc, Inter);
end loop;