Skip to content

Commit

Permalink
Branch over concatenation in assert message
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Aug 17, 2023
1 parent e2f2782 commit 4c14ee0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lower.c
Original file line number Diff line number Diff line change
Expand Up @@ -1884,6 +1884,8 @@ static bool lower_side_effect_free(tree_t expr)
if (kind == S_DIV || kind == S_DIV_PR || kind == S_DIV_RI
|| kind == S_REM || kind == S_MOD)
return false;
else if (kind == S_CONCAT)
return false; // Allocates memory
else if (!is_builtin(kind))
return false;

Expand Down
18 changes: 18 additions & 0 deletions test/lower/assert2.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
entity assert2 is
end entity;

architecture test of assert2 is
procedure test(x : integer; s : string) is
begin
assert x > 0 report "s=" & s; -- Message has allocation side-effect
end procedure;
begin

p1: process is
variable x : integer;
begin
test(-6, "hello");
wait;
end process;

end architecture;
20 changes: 20 additions & 0 deletions test/test_lower.c
Original file line number Diff line number Diff line change
Expand Up @@ -5241,6 +5241,25 @@ START_TEST(test_protpcall)
}
END_TEST

START_TEST(test_assert2)
{
input_from_file(TESTDIR "/lower/assert2.vhd");

run_elab();

vcode_unit_t vu = find_unit("WORK.ASSERT2.TEST(IS)");
vcode_select_unit(vu);

EXPECT_BB(0) = {
{ VCODE_OP_CONST, .value = 0 },
{ VCODE_OP_CMP, .cmp = VCODE_CMP_GT },
{ VCODE_OP_COND, .target = 2, .target_else = 1 },
};

CHECK_BB(0);
}
END_TEST

Suite *get_lower_tests(void)
{
Suite *s = suite_create("lower");
Expand Down Expand Up @@ -5368,6 +5387,7 @@ Suite *get_lower_tests(void)
tcase_add_test(tc, test_issue725);
tcase_add_test(tc, test_cond2);
tcase_add_test(tc, test_protpcall);
tcase_add_test(tc, test_assert2);
suite_add_tcase(s, tc);

return s;
Expand Down

0 comments on commit 4c14ee0

Please sign in to comment.