Skip to content

Commit

Permalink
Error rather than crash on incremental binding. Issue xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Dec 11, 2024
1 parent 8e2e229 commit 20ad2e8
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -9018,29 +9018,37 @@ static tree_t p_binding_indication(tree_t comp)

tree_t bind = NULL, unit = NULL;
if (optional(tUSE)) {
if ((bind = p_entity_aspect())) {
unit = find_binding(bind);
if ((bind = p_entity_aspect()) && (unit = find_binding(bind))) {
tree_set_ref(bind, unit);

if (unit != NULL) unit = primary_unit_of(unit);
unit = primary_unit_of(unit);
}
}
else
bind = tree_new(T_BINDING);

if (comp) {
insert_generics(nametab, comp);
insert_ports(nametab, comp);
}

if (peek() == tGENERIC) {
assert(bind != NULL); // XXX: check for open here
p_generic_map_aspect(bind, unit);
if (bind == NULL) {
consume(tGENERIC);
parse_error(CURRENT_LOC, "sorry, binding indication with generic map "
"aspect and OPEN entity aspect is not yet supported");
drop_tokens_until(tRPAREN);
}
else
p_generic_map_aspect(bind, unit);
}

if (peek() == tPORT) {
assert(bind != NULL); // XXX: check for open here
p_port_map_aspect(bind, unit);
if (bind == NULL) {
consume(tPORT);
parse_error(CURRENT_LOC, "sorry, binding indication with port map "
"aspect and OPEN entity aspect is not yet supported");
drop_tokens_until(tRPAREN);
}
else
p_port_map_aspect(bind, unit);
}

if (bind != NULL)
Expand Down
28 changes: 28 additions & 0 deletions test/parse/issue1096.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
entity ent is
generic (A: integer := 0);
end entity ent;

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

entity top is
end entity top;

architecture arch of top is
component ent is
generic (A: integer := 1);
end component ent;
for inst : ent use entity work.ent generic map (A => 2);
begin
inst : component ent generic map (A => 3);
end architecture arch;

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

configuration conf of top is
for arch
for others : ent -- OK (not yet supported)
generic map (A => 4);
end for;
end for;
end configuration conf;

20 changes: 20 additions & 0 deletions test/test_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -7054,6 +7054,25 @@ START_TEST(test_issue1091)
}
END_TEST

START_TEST(test_issue1096)
{
input_from_file(TESTDIR "/parse/issue1096.vhd");

const error_t expect[] = {
{ 24, "sorry, binding indication with generic map aspect and OPEN "
"entity aspect is not yet supported" },
{ -1, NULL }
};
expect_errors(expect);

parse_and_check(T_ENTITY, T_ENTITY, T_ARCH, T_CONFIGURATION);

fail_unless(parse() == NULL);

check_expected_errors();
}
END_TEST

Suite *get_parse_tests(void)
{
Suite *s = suite_create("parse");
Expand Down Expand Up @@ -7225,6 +7244,7 @@ Suite *get_parse_tests(void)
tcase_add_test(tc_core, test_pkgindecl);
tcase_add_test(tc_core, test_issue1090);
tcase_add_test(tc_core, test_issue1091);
tcase_add_test(tc_core, test_issue1096);
suite_add_tcase(s, tc_core);

return s;
Expand Down

0 comments on commit 20ad2e8

Please sign in to comment.