Skip to content

Commit

Permalink
Fix crash with unconstrained type in has_unique_driver. Fixes xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Aug 24, 2024
1 parent bc4f08b commit c1d10f9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ bool has_unique_driver(driver_set_t *ds, tree_t what)
return true;

type_t type = tree_type(what);
if (type_is_unconstrained(type))
return false;

int64_t length = 0, left = 0, right = 0;
range_kind_t rkind = RANGE_ERROR;
if (type_is_array(type) && dimension_of(type) == 1) {
Expand Down
17 changes: 17 additions & 0 deletions test/driver/issue953.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
entity issue953 is
end entity;

architecture test of issue953 is
signal s : bit_vector(1 to 2);
begin

-- Crash with unconstrained port in has_unique_driver
b: block is
port ( p : out bit_vector );
port map ( s );
begin
p(1) <= '1';
p(2) <= '0';
end block;

end architecture;
21 changes: 21 additions & 0 deletions test/test_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,26 @@ START_TEST(test_issue930)
}
END_TEST

START_TEST(test_issue953)
{
input_from_file(TESTDIR "/driver/issue953.vhd");

tree_t a = parse_check_and_simplify(T_ENTITY, T_ARCH);

tree_t b = tree_stmt(a, 0);
fail_unless(tree_kind(b) == T_BLOCK);

driver_set_t *ds = find_drivers(b);

tree_t p = tree_port(b, 0);
ck_assert(!has_unique_driver(ds, p));

free_drivers(ds);

fail_if_errors();
}
END_TEST

Suite *get_driver_tests(void)
{
Suite *s = suite_create("driver");
Expand All @@ -254,6 +274,7 @@ Suite *get_driver_tests(void)
tcase_add_test(tc, test_unique2);
tcase_add_test(tc, test_unique3);
tcase_add_test(tc, test_issue930);
tcase_add_test(tc, test_issue953);
suite_add_tcase(s, tc);

return s;
Expand Down

0 comments on commit c1d10f9

Please sign in to comment.