aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-04-15 07:45:57 +0200
committerTristan Gingold <tgingold@free.fr>2021-04-15 07:45:57 +0200
commite2f0e4b59816b0b64a83fac22614c97a7bd7d85d (patch)
treeb379d953870b39c16cb295d47497066f37159619
parente5cf1849821cec0f3340babf69c29929d1d25fca (diff)
downloadghdl-e2f0e4b59816b0b64a83fac22614c97a7bd7d85d.tar.gz
ghdl-e2f0e4b59816b0b64a83fac22614c97a7bd7d85d.tar.bz2
ghdl-e2f0e4b59816b0b64a83fac22614c97a7bd7d85d.zip
synth: avoid crash in case of non-elaboratable generic.
-rw-r--r--src/synth/synth-decls.adb6
-rw-r--r--src/synth/synth-insts.adb8
2 files changed, 10 insertions, 4 deletions
diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb
index 1539b0039..b9207e0a6 100644
--- a/src/synth/synth-decls.adb
+++ b/src/synth/synth-decls.adb
@@ -792,7 +792,11 @@ package body Synth.Decls is
Val := Synth_Subtype_Conversion
(Ctxt, Val, Inter_Type, True, Assoc);
- pragma Assert (Is_Static (Val.Val));
+ if not Is_Static (Val.Val) then
+ Error_Msg_Synth
+ (+Assoc, "value of generic %i must be static", +Inter);
+ Val := No_Valtyp;
+ end if;
Create_Object (Sub_Inst, Inter, Val);
diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb
index 5937a793e..250fbcf61 100644
--- a/src/synth/synth-insts.adb
+++ b/src/synth/synth-insts.adb
@@ -994,9 +994,11 @@ package body Synth.Insts is
Inter := Get_Generic_Chain (Inst_Obj.Decl);
while Inter /= Null_Node loop
Vt := Get_Value (Inst_Obj.Syn_Inst, Inter);
- Pv := Memtyp_To_Pval (Get_Memtyp (Vt));
- Set_Param_Pval (Inst, Idx, Pv);
-
+ if Vt /= No_Valtyp then
+ -- Avoid errors
+ Pv := Memtyp_To_Pval (Get_Memtyp (Vt));
+ Set_Param_Pval (Inst, Idx, Pv);
+ end if;
Inter := Get_Chain (Inter);
Idx := Idx + 1;
end loop;