From 02effd78c948d522a61f6f3a8e8ca3cefe7519ab Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 1 Apr 2024 10:30:13 +0100 Subject: [PATCH] Add a separate tree kind for element resolution indication --- src/lower.c | 2 +- src/names.c | 2 +- src/parse.c | 2 +- src/sem.c | 2 +- src/tree.c | 7 +++++-- src/tree.h | 1 + test/test_parse.c | 2 +- 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lower.c b/src/lower.c index 00222f8e..f7e24435 100644 --- a/src/lower.c +++ b/src/lower.c @@ -7481,7 +7481,7 @@ static vcode_reg_t lower_resolution_func(lower_unit_t *lu, type_t type, else if (rname == NULL) return VCODE_INVALID_REG; - while (tree_kind(rname) == T_AGGREGATE) { + while (tree_kind(rname) == T_ELEM_RESOLUTION) { assert(type_is_array(type)); assert(tree_assocs(rname) == 1); diff --git a/src/names.c b/src/names.c index db13b657..ea4db7a3 100644 --- a/src/names.c +++ b/src/names.c @@ -1962,7 +1962,7 @@ void resolve_resolution(nametab_t *tab, tree_t rname, type_t type) { // Finding the resolution function is a special case of overload resolution - if (tree_kind(rname) == T_AGGREGATE) { + if (tree_kind(rname) == T_ELEM_RESOLUTION) { if (type_is_record(type)) error_at(tree_loc(rname), "sorry, record element resolution is not " "supported yet"); diff --git a/src/parse.c b/src/parse.c index b4e33248..ff4ead3b 100644 --- a/src/parse.c +++ b/src/parse.c @@ -3965,7 +3965,7 @@ static tree_t p_element_resolution(void) BEGIN("element resolution"); - tree_t t = tree_new(T_AGGREGATE); + tree_t t = tree_new(T_ELEM_RESOLUTION); do { tree_t a = tree_new(T_ASSOC); diff --git a/src/sem.c b/src/sem.c index 1d687919..4937df1d 100644 --- a/src/sem.c +++ b/src/sem.c @@ -83,7 +83,7 @@ static bool sem_check_resolution(type_t type, tree_t res) { // Resolution functions are described in LRM 93 section 2.4 - if (tree_kind(res) == T_AGGREGATE) { + if (tree_kind(res) == T_ELEM_RESOLUTION) { // VHDL-2008 element resolution assert(standard() >= STD_08); diff --git a/src/tree.c b/src/tree.c index 5048cc9e..4461a7ea 100644 --- a/src/tree.c +++ b/src/tree.c @@ -1,5 +1,5 @@ // -// Copyright (C) 2011-2023 Nick Gasson +// Copyright (C) 2011-2024 Nick Gasson // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -368,6 +368,9 @@ static const imask_t has_map[T_LAST_TREE_KIND] = { // T_INERTIAL (I_VALUE | I_TYPE), + + // T_ELEM_RESOLUTION + (I_ASSOCS), }; static const char *kind_text_map[T_LAST_TREE_KIND] = { @@ -408,7 +411,7 @@ static const char *kind_text_map[T_LAST_TREE_KIND] = { "T_VIEW_DECL", "T_PACKAGE_MAP", "T_COND_EXPR", "T_COND_VALUE", "T_COND_RETURN", "T_VIEW_ELEMENT", "T_MATCH_SELECT", "T_PROT_DECL", "T_DUMMY_DRIVER", - "T_GUARD", "T_INERTIAL", + "T_GUARD", "T_INERTIAL", "T_ELEM_RESOLUTION", }; static const change_allowed_t change_allowed[] = { diff --git a/src/tree.h b/src/tree.h index 9c19e432..672e58a8 100644 --- a/src/tree.h +++ b/src/tree.h @@ -381,6 +381,7 @@ typedef enum tree_kind { T_DUMMY_DRIVER, T_GUARD, T_INERTIAL, + T_ELEM_RESOLUTION, T_LAST_TREE_KIND } tree_kind_t; diff --git a/test/test_parse.c b/test/test_parse.c index 9d3ad5be..9eab3182 100644 --- a/test/test_parse.c +++ b/test/test_parse.c @@ -3681,7 +3681,7 @@ START_TEST(test_vhdl2008) fail_unless(type_kind(type) == T_SUBTYPE); fail_unless(type_has_resolution(type)); tree_t r = type_resolution(type); - fail_unless(tree_kind(r) == T_AGGREGATE); + fail_unless(tree_kind(r) == T_ELEM_RESOLUTION); tree_t p4 = tree_stmt(a, 4); fail_unless(tree_chars(tree_value(tree_stmt(p4, 0))) == 8); -- 2.39.2