diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-01-04 18:59:12 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-01-04 20:56:17 +0100 |
commit | a506cfc5066f9c8f05db335a01e4e12240e07987 (patch) | |
tree | cc875fc89451b65914462c7c3b68f0f095ff0f1a | |
parent | 1fb6cb173ecda149deb1f3afd7f04d52f7468f93 (diff) | |
download | ghdl-a506cfc5066f9c8f05db335a01e4e12240e07987.tar.gz ghdl-a506cfc5066f9c8f05db335a01e4e12240e07987.tar.bz2 ghdl-a506cfc5066f9c8f05db335a01e4e12240e07987.zip |
vhdl-prints: avoid assertion on empty hbox for simple loop
-rw-r--r-- | src/vhdl/vhdl-prints.adb | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/vhdl/vhdl-prints.adb b/src/vhdl/vhdl-prints.adb index 46bc0890e..0fc8ed3da 100644 --- a/src/vhdl/vhdl-prints.adb +++ b/src/vhdl/vhdl-prints.adb @@ -3110,13 +3110,22 @@ package body Vhdl.Prints is when Iir_Kind_For_Loop_Statement => Disp_For_Loop_Statement (Ctxt, Stmt); when Iir_Kind_While_Loop_Statement => - Start_Hbox (Ctxt); - Disp_Label (Ctxt, Stmt); - if Get_Condition (Stmt) /= Null_Iir then - Disp_Token (Ctxt, Tok_While); - Print (Ctxt, Get_Condition (Stmt)); - end if; - Close_Hbox (Ctxt); + declare + Cond : constant Iir := Get_Condition (Stmt); + begin + -- As an HBox cannot be empty, check before opening it. + if Get_Label (Stmt) /= Null_Identifier + or else Cond /= Null_Iir + then + Start_Hbox (Ctxt); + Disp_Label (Ctxt, Stmt); + if Get_Condition (Stmt) /= Null_Iir then + Disp_Token (Ctxt, Tok_While); + Print (Ctxt, Get_Condition (Stmt)); + end if; + Close_Hbox (Ctxt); + end if; + end; Start_Hbox (Ctxt); Disp_Token (Ctxt, Tok_Loop); Close_Hbox (Ctxt); |