From f486d8e8ee9c45a0df00f631269cc1f399ab5573 Mon Sep 17 00:00:00 2001 From: NikLeberg Date: Sun, 8 Dec 2024 07:00:51 +0000 Subject: [PATCH] Raise error when entity aspect is missing in binding indication. Issue #1091 --- src/parse.c | 11 +++++++---- test/parse/config.vhd | 12 ++++++++++++ test/test_parse.c | 11 +++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/parse.c b/src/parse.c index a32e76e12..b7e4f8b22 100644 --- a/src/parse.c +++ b/src/parse.c @@ -9003,14 +9003,17 @@ static tree_t p_entity_aspect(void) } } -static tree_t p_binding_indication(tree_t comp) +static tree_t p_binding_indication(tree_t comp, bool required) { // [ use entity_aspect ] [ generic_map_aspect ] [ port_map_aspect ] + // or with required = true + // use entity_aspect [ generic_map_aspect ] [ port_map_aspect ] BEGIN("binding indication"); tree_t bind = NULL, unit = NULL; - if (optional(tUSE)) { + if (required || peek() == tUSE) { + consume(tUSE); if ((bind = p_entity_aspect())) { unit = find_binding(bind); tree_set_ref(bind, unit); @@ -9061,7 +9064,7 @@ static void p_configuration_specification(tree_t parent) push_scope(nametab); - tree_t bind = p_binding_indication(comp); + tree_t bind = p_binding_indication(comp, true); consume(tSEMI); if (ids != NULL) { @@ -9145,7 +9148,7 @@ static void p_component_configuration(tree_t unit) push_scope(nametab); // TODO: should be optional - tree_t bind = p_binding_indication(comp); + tree_t bind = p_binding_indication(comp, false); consume(tSEMI); tree_t bcfg = NULL; diff --git a/test/parse/config.vhd b/test/parse/config.vhd index bab1e159f..281dbfe20 100644 --- a/test/parse/config.vhd +++ b/test/parse/config.vhd @@ -74,3 +74,15 @@ configuration use_pack_ent of ent is end for; end for; end configuration; + +entity b is +end entity b; + +architecture rtl of b is + component ent + end component; + + for ent0 : ent; -- Error +begin + ent0: ent; +end architecture rtl; diff --git a/test/test_parse.c b/test/test_parse.c index fd0dd6b91..3f30973e4 100644 --- a/test/test_parse.c +++ b/test/test_parse.c @@ -2900,6 +2900,7 @@ START_TEST(test_config) { 45, "cannot find architecture BAD of entity WORK.ENT" }, { 52, "P is not a block that can be configured" }, { 55, "instance P not found" }, + { 85, "unexpected ; while parsing binding indication, expecting use" }, { -1, NULL } }; expect_errors(expect); @@ -2979,6 +2980,16 @@ START_TEST(test_config) fail_unless(tree_kind(c) == T_CONFIGURATION); lib_put(lib_work(), c); + e = parse(); + fail_if(e == NULL); + fail_unless(tree_kind(e) == T_ENTITY); + lib_put(lib_work(), e); + + e = parse(); + fail_if(e == NULL); + fail_unless(tree_kind(e) == T_ARCH); + lib_put(lib_work(), e); + c = parse(); fail_unless(c == NULL);