From 399f99cb22ca3fc54f5b9adc85c0cabaae1328c4 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 29 Apr 2022 19:39:25 +0200 Subject: synth: avoid a crash after an error --- src/synth/synth-vhdl_expr.adb | 15 +++++++++++++++ src/synth/synth-vhdl_static_proc.adb | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/src/synth/synth-vhdl_expr.adb b/src/synth/synth-vhdl_expr.adb index 0ad0b4420..6036d6394 100644 --- a/src/synth/synth-vhdl_expr.adb +++ b/src/synth/synth-vhdl_expr.adb @@ -358,6 +358,21 @@ package body Synth.Vhdl_Expr is Off, W, Vec, Vec_Off, Has_Zx); exit when W = 0; end loop; + when Type_Access => + -- Accesses cannot be indexed or sliced. + -- Just fill with 'X'. + pragma Assert (Off = 0 and W >= Typ.W); + for I in 0 .. Typ.W - 1 loop + declare + Idx : constant Digit_Index := Digit_Index (Vec_Off / 32); + Pos : constant Natural := Natural (Vec_Off mod 32); + begin + Vec (Idx).Val := Vec (Idx).Val or Shift_Left (1, Pos); + Vec (Idx).Zx := Vec (Idx).Zx or Shift_Left (1, Pos); + end; + Vec_Off := Vec_Off + 1; + end loop; + W := W - Typ.W; when others => raise Internal_Error; end case; diff --git a/src/synth/synth-vhdl_static_proc.adb b/src/synth/synth-vhdl_static_proc.adb index 5dc31318b..0bdb785f0 100644 --- a/src/synth/synth-vhdl_static_proc.adb +++ b/src/synth/synth-vhdl_static_proc.adb @@ -32,6 +32,10 @@ package body Synth.Vhdl_Static_Proc is Param : constant Valtyp := Get_Value (Syn_Inst, Inter); Val : Heap_Index; begin + if not Is_Static (Param.Val) then + -- Certainly an error (and certainly already reported). + return; + end if; Val := Read_Access (Param); if Val /= Null_Heap_Index then Elab.Vhdl_Heap.Synth_Deallocate (Val); -- cgit v1.2.3