From f48ec7d566fd005ca59e039a46dfccc8c77c8a0a Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 17 May 2024 17:32:34 +0100 Subject: [PATCH] Fix crash when case? alternative contains multiple choices Issue #890 --- NEWS.md | 2 ++ src/lower.c | 2 ++ test/regress/issue890.vhd | 42 +++++++++++++++++++++++++++++++++++++++ test/regress/testlist.txt | 1 + 4 files changed, 47 insertions(+) create mode 100644 test/regress/issue890.vhd diff --git a/NEWS.md b/NEWS.md index 5035671d..508f483d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ ## Unreleased changes - Type and package generics now work correctly with components and configurations (#883). +- Fixed a crash when a matching `case?` alternative contains multiple + choices (#890). ## Version 1.12.2 - 2024-05-15 - Fixed a crash when `'transaction` is used with a record type. diff --git a/src/lower.c b/src/lower.c index e7c988c1..ac4741e2 100644 --- a/src/lower.c +++ b/src/lower.c @@ -7275,6 +7275,8 @@ static void lower_match_case(lower_unit_t *lu, tree_t stmt, loop_stack_t *loops) else emit_cond(cmp_reg, hit_bb, skip_bb); + vcode_select_block(skip_bb); + if (tmp_var != VCODE_INVALID_VAR) lower_release_temp(lu, tmp_var); } diff --git a/test/regress/issue890.vhd b/test/regress/issue890.vhd new file mode 100644 index 00000000..dec680e4 --- /dev/null +++ b/test/regress/issue890.vhd @@ -0,0 +1,42 @@ +entity issue890 is +end entity; + +library ieee; +use ieee.std_logic_1164.all; + +architecture test of issue890 is + constant A : std_logic_vector(1 to 3) := "101"; + constant B : std_logic_vector(1 to 3) := "-1-"; + constant C : std_logic_vector(1 to 3) := "000"; + + signal i : std_logic_vector(1 to 3); + signal o : natural; +begin + + gen: process (all) is + begin + case? i is + when A => o <= 5; + when B | C => o <= 42; + when others => o <= 0; + end case?; + end process; + + check: process is + begin + i <= "000"; + wait for 1 ns; + assert o = 42; + i <= "111"; + wait for 1 ns; + assert o = 42; + i <= "101"; + wait for 1 ns; + assert o = 5; + i <= "001"; + wait for 1 ns; + assert o = 0; + wait; + end process; + +end architecture; diff --git a/test/regress/testlist.txt b/test/regress/testlist.txt index 3041e1af..6c5d9106 100644 --- a/test/regress/testlist.txt +++ b/test/regress/testlist.txt @@ -980,3 +980,4 @@ genpack18 normal,2008 implicit6 normal bounds44 fail,gold,2008 issue887 normal +issue890 normal,2008 -- 2.39.2