Skip to content

Commit

Permalink
Tweak reporting of invalid formal names
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Dec 11, 2024
1 parent 6276c46 commit 8e2e229
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
23 changes: 11 additions & 12 deletions src/names.c
Original file line number Diff line number Diff line change
Expand Up @@ -1782,16 +1782,6 @@ tree_t resolve_name(nametab_t *tab, const loc_t *loc, ident_t name)
else if (name == well_known(W_ERROR)) {
// Was a parse error, suppress further errors
}
else if (tab->top_scope->formal_kind != F_NONE
&& tab->top_scope->formal_fn != NULL) {
diag_t *d = diag_new(DIAG_ERROR, loc);

if (tab->top_scope->formal_fn != NULL)
(*tab->top_scope->formal_fn)(d, name, tab->top_scope->formal_arg);

diag_emit(d);
tab->top_scope->formal_fn = NULL; // Suppress further errors
}
else if (tab->top_scope->overload && !tab->top_scope->overload->error) {
diag_t *d = diag_new(DIAG_ERROR, loc);
diag_printf(d, "no possible overload of %s has formal %s",
Expand All @@ -1817,8 +1807,17 @@ tree_t resolve_name(nametab_t *tab, const loc_t *loc, ident_t name)
diag_emit(d);
tab->top_scope->overload->error = true;
}
else if (tab->top_scope->formal_kind != F_NONE)
; // Was earlier error
else if (tab->top_scope->formal_kind != F_NONE) {
diag_t *d = diag_new(DIAG_ERROR, loc);

if (tab->top_scope->formal_fn != NULL)
(*tab->top_scope->formal_fn)(d, name, tab->top_scope->formal_arg);
else
diag_printf(d, "invalid formal name %s", istr(name));

diag_emit(d);
tab->top_scope->suppress = true; // Suppress further errors
}
else if (tab->top_scope->overload == NULL) {
diag_t *d = diag_new(DIAG_ERROR, loc);

Expand Down
4 changes: 1 addition & 3 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -3127,9 +3127,7 @@ static tree_t p_formal_part(type_t *signature)
*signature = p_signature();
tree_set_loc(name, CURRENT_LOC);
}
if (!(tree_has_type(name) && type_is_none(tree_type(name))))
break;
// Fall-through
break;

default:
parse_error(CURRENT_LOC, "illegal formal designator");
Expand Down
5 changes: 1 addition & 4 deletions test/parse/issue1091.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ end;

--------------------------------------------------------------------------------

LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;

PACKAGE Vital_Memory IS END PACKAGE Vital_Memory;
PACKAGE BODY Vital_Memory IS
PROCEDURE InternalTimingCheck (CONSTANT SetupHigh : IN TIME := 0 ns) IS
Expand All @@ -23,6 +20,6 @@ PACKAGE BODY Vital_Memory IS

PROCEDURE VitalMemorySetupHoldCheck (SIGNAL TestSignal : IN time) IS
BEGIN
InternalTimingCheck (IEEE.SetupHigh => TestSignal);
InternalTimingCheck (WORK.SetupHigh => TestSignal);
END VitalMemorySetupHoldCheck;
END PACKAGE BODY Vital_Memory;
2 changes: 1 addition & 1 deletion test/test_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -7041,7 +7041,7 @@ START_TEST(test_issue1091)

const error_t expect[] = {
{ 10, "illegal formal designator" },
{ 26, "illegal formal designator" },
{ 23, "invalid formal name WORK.SETUPHIGH" },
{ -1, NULL }
};
expect_errors(expect);
Expand Down
1 change: 1 addition & 0 deletions test/test_sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -3817,6 +3817,7 @@ START_TEST(test_issue1020)
input_from_file(TESTDIR "/sem/issue1020.vhd");

const error_t expect[] = {
{ 13, "invalid formal name V" },
{ 13, "sorry, conversions are not yet supported here" },
{ -1, NULL }
};
Expand Down

0 comments on commit 8e2e229

Please sign in to comment.