From e2f0e4b59816b0b64a83fac22614c97a7bd7d85d Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Thu, 15 Apr 2021 07:45:57 +0200 Subject: synth: avoid crash in case of non-elaboratable generic. --- src/synth/synth-decls.adb | 6 +++++- src/synth/synth-insts.adb | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/synth') 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; -- cgit v1.2.3