aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/synth-insts.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-19 08:07:30 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-19 08:07:30 +0200
commit6113d4e6096d411c727a4e73076b2dfed7528b30 (patch)
treeeffa93ef87e1757bd04f8cb078f4c76788c35baf /src/synth/synth-insts.adb
parentc98d8da00782800fa7b9984d2b8a3a52a32f2de8 (diff)
downloadghdl-6113d4e6096d411c727a4e73076b2dfed7528b30.tar.gz
ghdl-6113d4e6096d411c727a4e73076b2dfed7528b30.tar.bz2
ghdl-6113d4e6096d411c727a4e73076b2dfed7528b30.zip
synth-insts: fix a crash on subtype indication of blackbox components.
For #1239
Diffstat (limited to 'src/synth/synth-insts.adb')
-rw-r--r--src/synth/synth-insts.adb16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb
index 2013d4939..e4c5cf608 100644
--- a/src/synth/synth-insts.adb
+++ b/src/synth/synth-insts.adb
@@ -407,14 +407,16 @@ package body Synth.Insts is
Nbr_Inputs := 0;
Nbr_Outputs := 0;
while Is_Valid (Inter) loop
- -- Elaborate the type...
- Synth_Declaration_Type (Syn_Inst, Inter);
- Inter_Typ := Get_Subtype_Object (Syn_Inst, Get_Type (Inter));
- if not Is_Bounded_Type (Inter_Typ) then
- -- ... but get it from the template (so that unbounded types
- -- are bounded).
- Inter_Typ := Get_Value (Params.Syn_Inst, Inter).Typ;
+ -- Copy the type from PARAMS if needed. The subtype indication of
+ -- the port may reference objects that aren't anymore reachable
+ -- (particularly if it is a port of a component). So the subtype
+ -- cannot be regularly elaborated.
+ -- Also, for unconstrained subtypes, we need the constraint.
+ Inter_Typ := Get_Value (Params.Syn_Inst, Inter).Typ;
+ if Get_Declaration_Type (Inter) /= Null_Node then
+ Create_Subtype_Object (Syn_Inst, Get_Type (Inter), Inter_Typ);
end if;
+
case Mode_To_Port_Kind (Get_Mode (Inter)) is
when Port_In =>
Val := Create_Value_Net (No_Net, Inter_Typ);