Skip to content

Commit

Permalink
Fix crash with qualified expression. Fixes #934
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Aug 8, 2024
1 parent 10d92b9 commit 059d264
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 4 additions & 11 deletions src/lower.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions test/lower/issue934.vhd
Original file line number Diff line number Diff line change
@@ -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;
30 changes: 30 additions & 0 deletions test/test_lower.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 059d264

Please sign in to comment.