Skip to content

Commit

Permalink
Raise error if reference is used as formal part. Issue nickg#1091
Browse files Browse the repository at this point in the history
  • Loading branch information
NikLeberg committed Dec 9, 2024
1 parent 361a948 commit d1814bb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -3109,6 +3109,12 @@ static tree_t p_formal_part(type_t *signature)
tree_t name = p_name(0);

switch (tree_kind(name)) {
case T_RECORD_REF:
case T_ARRAY_REF:
case T_ARRAY_SLICE:
case T_TYPE_CONV:
break;

case T_FCALL:
if (tree_params(name) == 1)
tree_set_flag(name, TREE_F_CONVERSION);
Expand All @@ -3121,13 +3127,9 @@ static tree_t p_formal_part(type_t *signature)
*signature = p_signature();
tree_set_loc(name, CURRENT_LOC);
}
break;

case T_RECORD_REF:
case T_ARRAY_REF:
case T_ARRAY_SLICE:
case T_TYPE_CONV:
break;
if (!(tree_has_type(name) && type_is_none(tree_type(name))))
break;
// Fall-through

default:
parse_error(CURRENT_LOC, "illegal formal designator");
Expand Down
17 changes: 17 additions & 0 deletions test/parse/issue1091.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,20 @@ architecture struct_adderN of adderN is
begin
u: adder port map(addend'last_value => addend);
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
BEGIN
END InternalTimingCheck;

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

const error_t expect[] = {
{ 10, "illegal formal designator" },
{ 26, "illegal formal designator" },
{ -1, NULL }
};
expect_errors(expect);

parse_and_check(T_ENTITY, T_ARCH);
parse_and_check(T_ENTITY, T_ARCH, T_PACKAGE, T_PACK_BODY);

fail_unless(parse() == NULL);

Expand Down

0 comments on commit d1814bb

Please sign in to comment.