From b78ecbf108476502956bcaf29dfa73271a768f17 Mon Sep 17 00:00:00 2001 From: NikLeberg Date: Fri, 1 Nov 2024 11:45:36 +0000 Subject: [PATCH] Fix warning of hidden declaration. Issue #1038 --- NEWS.md | 1 + src/names.c | 2 +- test/parse/issue1038.vhd | 11 +++++++++++ test/test_parse.c | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 test/parse/issue1038.vhd diff --git a/NEWS.md b/NEWS.md index c20066821..71218d571 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/src/names.c b/src/names.c index f3a99d766..07dca8e71 100644 --- a/src/names.c +++ b/src/names.c @@ -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 diff --git a/test/parse/issue1038.vhd b/test/parse/issue1038.vhd new file mode 100644 index 000000000..ab87d1e27 --- /dev/null +++ b/test/parse/issue1038.vhd @@ -0,0 +1,11 @@ +package foo_pkg is + signal sig: integer; +end foo_pkg; + +package body foo_pkg is + package bar_pkg is + signal sig: integer; + end bar_pkg; + package body bar_pkg is + end package body bar_pkg; +end package body foo_pkg; diff --git a/test/test_parse.c b/test/test_parse.c index e2303a87a..83fce2d81 100644 --- a/test/test_parse.c +++ b/test/test_parse.c @@ -6912,6 +6912,21 @@ 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"); + + parse_and_check(T_PACKAGE, T_PACK_BODY); + + fail_unless(parse() == NULL); + + fail_if_errors(); +} +END_TEST + Suite *get_parse_tests(void) { Suite *s = suite_create("parse"); @@ -7076,6 +7091,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;