aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/verilog
diff options
context:
space:
mode:
authorXiretza <xiretza@xiretza.xyz>2021-03-18 21:53:02 +0100
committerZachary Snow <zachary.j.snow@gmail.com>2021-03-21 19:35:13 -0400
commit92d5550a90558a0292c8ac63cecabb2de30eb6aa (patch)
tree58ed982822080494e7ca632c0e9c1d566f15fca2 /frontends/verilog
parent4f4e70876f06738fa7dda24e01ac296fe318264a (diff)
downloadyosys-92d5550a90558a0292c8ac63cecabb2de30eb6aa.tar.gz
yosys-92d5550a90558a0292c8ac63cecabb2de30eb6aa.tar.bz2
yosys-92d5550a90558a0292c8ac63cecabb2de30eb6aa.zip
verilog: check entire user type stack for type definition
Diffstat (limited to 'frontends/verilog')
-rw-r--r--frontends/verilog/verilog_parser.y18
1 files changed, 12 insertions, 6 deletions
diff --git a/frontends/verilog/verilog_parser.y b/frontends/verilog/verilog_parser.y
index 91b7afddf..e4b3258c2 100644
--- a/frontends/verilog/verilog_parser.y
+++ b/frontends/verilog/verilog_parser.y
@@ -163,12 +163,18 @@ static bool isInLocalScope(const std::string *name)
static AstNode *getTypeDefinitionNode(std::string type_name)
{
- // return the definition nodes from the typedef statement
- auto user_types = user_type_stack.back();
- log_assert(user_types->count(type_name) > 0);
- auto typedef_node = (*user_types)[type_name];
- log_assert(typedef_node->type == AST_TYPEDEF);
- return typedef_node->children[0];
+ // check current scope then outer scopes for a name
+ for (auto it = user_type_stack.rbegin(); it != user_type_stack.rend(); ++it) {
+ if ((*it)->count(type_name) > 0) {
+ // return the definition nodes from the typedef statement
+ auto typedef_node = (**it)[type_name];
+ log_assert(typedef_node->type == AST_TYPEDEF);
+ return typedef_node->children[0];
+ }
+ }
+
+ // The lexer recognized the name as a TOK_USER_TYPE, but now we can't find it anymore?
+ log_error("typedef for user type `%s' not found", type_name.c_str());
}
static AstNode *copyTypeDefinition(std::string type_name)