Skip to content

Commit

Permalink
Fix warning of hidden declaration. Issue #1038
Browse files Browse the repository at this point in the history
  • Loading branch information
NikLeberg committed Nov 1, 2024
1 parent b5b1548 commit 57fb8b9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Added a warning for potential infinite loops in processes without
sensitivity and lacking any wait statements (from @NikLeberg).
- Fixed a crash when `'last_value` is used with record types (#1043).
- Several other minor bugs were resolved (#1038).

## Version 1.14.1 - 2024-10-26
- Fixed an error when using the `work` library alias and the working
Expand Down
2 changes: 1 addition & 1 deletion src/names.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ static void warn_hidden_decl(scope_t *s, decl_t *outer, tree_t inner)
// to avoid false-positives and cases that may be intentional

for (scope_t *it = s; it && it != outer->origin; it = it->parent) {
if (s->container == NULL)
if (it->container == NULL)
return; // Ignore ports in component, etc.
else if (is_subprogram(it->container))
return; // Do not warn when subprogram parameters hide ports
Expand Down
13 changes: 13 additions & 0 deletions test/parse/issue1038.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package foo_pkg is
end foo_pkg;

package body foo_pkg is
shared variable var : integer;

package bar_pkg is
end bar_pkg;

package body bar_pkg is
shared variable var : integer;
end package body bar_pkg;
end package body foo_pkg;
22 changes: 22 additions & 0 deletions test/test_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -6912,6 +6912,27 @@ START_TEST(test_issue991)
}
END_TEST

START_TEST(test_issue1038)
{
opt_set_int(OPT_RELAXED, 1);
set_standard(STD_08);

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

const error_t expect[] = {
{ 5, "shared variable VAR must have protected type" },
{ -1, NULL }
};
expect_errors(expect);

parse_and_check(T_PACKAGE);

fail_unless(parse() == NULL);

fail_if_errors();
}
END_TEST

Suite *get_parse_tests(void)
{
Suite *s = suite_create("parse");
Expand Down Expand Up @@ -7076,6 +7097,7 @@ Suite *get_parse_tests(void)
tcase_add_test(tc_core, test_issue961);
tcase_add_test(tc_core, test_issue977);
tcase_add_test(tc_core, test_issue991);
tcase_add_test(tc_core, test_issue1038);
suite_add_tcase(s, tc_core);

return s;
Expand Down

0 comments on commit 57fb8b9

Please sign in to comment.