Skip to content

Commit

Permalink
Fix crash overriding predefined function in package body only
Browse files Browse the repository at this point in the history
Issue #760
  • Loading branch information
nickg committed Sep 17, 2023
1 parent d9c6fd3 commit 3a505ad
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- Fixed a memory leak in the `--print-deps` command.
- Fixed a crash when evaluating globally static expressions during
elaboration with coverage enabled (#759).
- Fixed an analysis crash where a predefined function for a type
declared in a package is overridden in the package body only (#760).

## Version 1.10.2 - 2023-08-20
- Fixed a crash due to an array bounds check being incorrectly optimised
Expand Down
3 changes: 2 additions & 1 deletion src/names.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,8 @@ static symbol_t *make_visible(scope_t *s, ident_t name, tree_t decl,
&& (tree_flags(dd->tree) & TREE_F_PREDEFINED)) {
// Allow pre-defined operators be to hidden by
// user-defined subprograms in the same region
tree_set_flag(dd->tree, TREE_F_HIDDEN);
if (!tree_frozen(dd->tree))
tree_set_flag(dd->tree, TREE_F_HIDDEN); // Will be deleted later
dd->visibility = HIDDEN;
}
else if (is_forward_decl(decl, dd->tree)) {
Expand Down
11 changes: 11 additions & 0 deletions test/parse/issue760.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package issue760 is
type t_array is array (natural range <>) of integer;
end package;

package body issue760 is
-- Hides predef defined in package header
impure function to_string (x : t_array) return string is
begin
return "";
end function;
end package body;
23 changes: 23 additions & 0 deletions test/test_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -5665,6 +5665,28 @@ START_TEST(test_issue751)
}
END_TEST

START_TEST(test_issue760)
{
set_standard(STD_19);

input_from_file(TESTDIR "/parse/issue760.vhd");

tree_t p = parse();
fail_if(p == NULL);
fail_unless(tree_kind(p) == T_PACKAGE);

lib_put(lib_work(), p);

tree_t b = parse();
fail_if(b == NULL);
fail_unless(tree_kind(b) == T_PACK_BODY);

fail_unless(parse() == NULL);

fail_if_errors();
}
END_TEST

Suite *get_parse_tests(void)
{
Suite *s = suite_create("parse");
Expand Down Expand Up @@ -5784,6 +5806,7 @@ Suite *get_parse_tests(void)
tcase_add_test(tc_core, test_issue727);
tcase_add_test(tc_core, test_visibility8);
tcase_add_test(tc_core, test_issue751);
tcase_add_test(tc_core, test_issue760);
suite_add_tcase(s, tc_core);

return s;
Expand Down

0 comments on commit 3a505ad

Please sign in to comment.