Skip to content

Commit

Permalink
Generic actuals do not need to be globally static. Fixes #886
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed May 8, 2024
1 parent 1e7e52a commit 6f319ea
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -4909,10 +4909,7 @@ static bool sem_check_generic_actual(formal_map_t *formals, int nformals,
"generic %s", type_pp(tree_type(value)), type_pp(type),
istr(tree_ident(decl)));

if (!sem_globally_static(value))
sem_error(value, "actual associated with generic %s must be "
"a globally static expression", istr(tree_ident(decl)));

sem_check_static_elab(value);
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion test/sem/gensub.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ begin
return y + t; -- Error
end function;

function inner_inst is new inner generic map (q => t, y => x); -- Error
function inner_inst is new inner generic map (q => t, y => x); -- OK (???)
begin
return inner_inst;
end function;
Expand Down
3 changes: 1 addition & 2 deletions test/test_sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ START_TEST(test_generics)
{ 48, "no visible declaration for X" },
{ 58, "invalid object class signal for generic Y" },
{ 68, "no visible declaration for Y" },
{ 110, "with generic X must be a globally static expression" },
{ 110, "cannot reference signal SX during static elaboration" },
{ 116, "unexpected integer while parsing name" },
{ 115, "missing actual for generic X without a default expression" },
{ 119, "invalid name in generic map" },
Expand Down Expand Up @@ -2820,7 +2820,6 @@ START_TEST(test_gensub)
{ 44, "cannot call uninstantiated function ADDER" },
{ 50, "cannot call uninstantiated procedure DO_STUFF" },
{ 57, "no matching operator \"+\" [Q, T return Q]" },
{ 60, "actual associated with generic Y must be a globally static" },
{ 69, "subtype of generic X does not match type INTEGER in spec" },
{ 75, "subprogram TEST2 declaration has 1 generic but body has 2" },
{ 93, "multiple visible uninstantiated subprograms with name TEST1" },
Expand Down

0 comments on commit 6f319ea

Please sign in to comment.