From bb37eb38f9f45a631ceb60a5121756b37a61d8c5 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 30 Sep 2024 20:24:49 +0100 Subject: [PATCH] Missing call to sem_check for HDL expressions in PSL. Issue #1001 --- src/psl/psl-sem.c | 4 ++++ test/psl/issue1001.vhd | 16 ++++++++++++++++ test/test_psl.c | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 test/psl/issue1001.vhd diff --git a/src/psl/psl-sem.c b/src/psl/psl-sem.c index 0f96f0e0c..fcb449f55 100644 --- a/src/psl/psl-sem.c +++ b/src/psl/psl-sem.c @@ -18,6 +18,7 @@ #include "util.h" #include "diag.h" #include "names.h" +#include "phase.h" #include "psl/psl-node.h" #include "psl/psl-phase.h" #include "type.h" @@ -139,6 +140,9 @@ static void psl_check_hdl_expr(psl_node_t p, nametab_t *tab) assert(psl_type(p) == PSL_TYPE_BOOLEAN); + if (!sem_check(value, tab)) + return; + type_t std_bool = std_type(NULL, STD_BOOLEAN); bool ok = type_eq(type, std_bool); diff --git a/test/psl/issue1001.vhd b/test/psl/issue1001.vhd new file mode 100644 index 000000000..2ace25d77 --- /dev/null +++ b/test/psl/issue1001.vhd @@ -0,0 +1,16 @@ +entity issue1001 is +end entity; + +architecture test of issue1001 is + signal x, y : bit; + + function f (v : bit_vector) return bit is + begin + return v(v'left); + end function; +begin + + assert always onehot(x); -- Error + assert always x -> f(y); -- Error + +end architecture; diff --git a/test/test_psl.c b/test/test_psl.c index 76361f938..def773fe9 100644 --- a/test/test_psl.c +++ b/test/test_psl.c @@ -312,6 +312,25 @@ START_TEST(test_issue910) } END_TEST +START_TEST(test_issue1001) +{ + set_standard(STD_08); + + input_from_file(TESTDIR "/psl/issue1001.vhd"); + + const error_t expect[] = { + { 13, "no matching subprogram ONEHOT [BIT return BOOLEAN | BIT]" }, + { 14, "type of actual BIT does not match formal V type BIT_VECTOR" }, + { -1, NULL } + }; + expect_errors(expect); + + parse_and_check(T_ENTITY, T_ARCH); + + check_expected_errors(); +} +END_TEST + Suite *get_psl_tests(void) { Suite *s = suite_create("psl"); @@ -324,6 +343,7 @@ Suite *get_psl_tests(void) tcase_add_test(tc_core, test_parse4); tcase_add_test(tc_core, test_parse5); tcase_add_test(tc_core, test_issue910); + tcase_add_test(tc_core, test_issue1001); suite_add_tcase(s, tc_core); return s;