From 4c14ee0cd0ea4b913304293250497c6232ac5703 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Thu, 17 Aug 2023 22:33:40 +0100 Subject: [PATCH] Branch over concatenation in assert message --- src/lower.c | 2 ++ test/lower/assert2.vhd | 18 ++++++++++++++++++ test/test_lower.c | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 test/lower/assert2.vhd diff --git a/src/lower.c b/src/lower.c index be2542e73..090ce1643 100644 --- a/src/lower.c +++ b/src/lower.c @@ -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; diff --git a/test/lower/assert2.vhd b/test/lower/assert2.vhd new file mode 100644 index 000000000..c10c6d07f --- /dev/null +++ b/test/lower/assert2.vhd @@ -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; diff --git a/test/test_lower.c b/test/test_lower.c index ddec455a0..53b3ca7f7 100644 --- a/test/test_lower.c +++ b/test/test_lower.c @@ -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"); @@ -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;