From b91a9fbbef7328f6f041f4ddda01dbbd7e156cfb Mon Sep 17 00:00:00 2001
From: Tristan Gingold <tgingold@free.fr>
Date: Wed, 4 Jan 2023 19:45:11 +0100
Subject: elab-vhdl_debug: avoid a crash on error in print

---
 src/synth/elab-vhdl_debug.adb | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

(limited to 'src/synth')

diff --git a/src/synth/elab-vhdl_debug.adb b/src/synth/elab-vhdl_debug.adb
index 1ea810734..9b0a25454 100644
--- a/src/synth/elab-vhdl_debug.adb
+++ b/src/synth/elab-vhdl_debug.adb
@@ -1377,14 +1377,18 @@ package body Elab.Vhdl_Debug is
          --  Res := Execute_Name (Dbg_Cur_Frame, Expr, True);
          raise Internal_Error;
       else
+         --  TODO: check EXPR is an expression.
+         --  TODO: protected object.
          Res := Synth.Vhdl_Expr.Synth_Expression (Cur_Inst, Expr);
       end if;
-      if Res.Val.Kind = Value_Memory then
-         Disp_Memtyp (Get_Memtyp (Res), Get_Type (Expr));
-      else
-         Elab.Vhdl_Values.Debug.Debug_Valtyp (Res);
+      if Res /= No_Valtyp then
+         if Res.Val.Kind = Value_Memory then
+            Disp_Memtyp (Get_Memtyp (Res), Get_Type (Expr));
+         else
+            Elab.Vhdl_Values.Debug.Debug_Valtyp (Res);
+         end if;
+         New_Line;
       end if;
-      New_Line;
 
       --  Free value
       Release_Expr_Pool (Marker);
-- 
cgit v1.2.3