diff --git a/NEWS.md b/NEWS.md index b2494c0af..1c958de44 100644 --- a/NEWS.md +++ b/NEWS.md @@ -21,6 +21,8 @@ errors due to excessive command line length. - Fixed a bug which prevented VCD files from being generated on Windows systems using the UCRT runtime library (#637). +- Fixed a crash when the type of a qualified expression is an + unconstrained array-of-array (#934). ## Version 1.13.1 - 2024-07-25 - Windows installer was missing some standard library files. diff --git a/src/lower.c b/src/lower.c index 169c0a822..c34fa8c44 100644 --- a/src/lower.c +++ b/src/lower.c @@ -5007,17 +5007,10 @@ static vcode_reg_t lower_qualified(lower_unit_t *lu, tree_t expr) vcode_reg_t value_reg = lower_rvalue(lu, value); - if (type_is_array(to_type)) { - const bool from_const = type_const_bounds(from_type); - const bool to_const = type_const_bounds(to_type); - - if (to_const && !from_const) - return lower_array_data(value_reg); - else if (!to_const && from_const) - return lower_wrap(lu, from_type, value_reg); - } - - return value_reg; + if (type_is_array(to_type)) + return lower_coerce_arrays(lu, from_type, to_type, value_reg); + else + return value_reg; } static vcode_reg_t lower_cond_value(lower_unit_t *lu, tree_t expr) diff --git a/test/lower/issue934.vhd b/test/lower/issue934.vhd new file mode 100644 index 000000000..54c4c671f --- /dev/null +++ b/test/lower/issue934.vhd @@ -0,0 +1,19 @@ +entity issue934 is +end entity; + +architecture test of issue934 is + type t_slv_array is array (natural range <>) of bit_vector; + + procedure proc (x : t_slv_array) is + begin + end procedure; + +begin + + check: process is + begin + proc(x => t_slv_array'((x"01", x"02"))); + wait; + end process; + +end architecture; diff --git a/test/test_lower.c b/test/test_lower.c index fec8a6d98..3edfcfe24 100644 --- a/test/test_lower.c +++ b/test/test_lower.c @@ -6258,6 +6258,35 @@ START_TEST(test_issue859) } END_TEST +START_TEST(test_issue934) +{ + set_standard(STD_08); + + input_from_file(TESTDIR "/lower/issue934.vhd"); + + run_elab(); + + vcode_unit_t vu = find_unit("WORK.ISSUE934.CHECK"); + vcode_select_unit(vu); + + EXPECT_BB(1) = { + { VCODE_OP_CONTEXT_UPREF, .hops = 1 }, + { VCODE_OP_CONST, .value = 0 }, + { VCODE_OP_CONST, .value = 1 }, + { VCODE_OP_CONST_ARRAY, .length = 16 }, + { VCODE_OP_ADDRESS_OF }, + { VCODE_OP_CONST, .value = 0 }, + { VCODE_OP_CONST, .value = 1 }, + { VCODE_OP_CONST, .value = 7 }, + { VCODE_OP_WRAP }, + { VCODE_OP_FCALL, .func = "*PROC" }, + { VCODE_OP_WAIT, .target = 2 }, + }; + + CHECK_BB(1); +} +END_TEST + Suite *get_lower_tests(void) { Suite *s = suite_create("lower"); @@ -6403,6 +6432,7 @@ Suite *get_lower_tests(void) tcase_add_test(tc, test_issue844); tcase_add_test(tc, test_trigger1); tcase_add_test(tc, test_issue859); + tcase_add_test(tc, test_issue934); suite_add_tcase(s, tc); return s;