Add informational messages that point to declaration after use.
This commit is contained in:
parent
d043c1fa44
commit
f08ff895af
12
elab_expr.cc
12
elab_expr.cc
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999-2023 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 1999-2024 Stephen Williams (steve@icarus.com)
|
||||
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
|
|
@ -4495,6 +4495,11 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
|
|||
if (!sr.net) {
|
||||
cerr << get_fileline() << ": error: Unable to bind variable `"
|
||||
<< path_ << "' in `" << scope_path(scope) << "'" << endl;
|
||||
if (sr.decl_after_use) {
|
||||
cerr << sr.decl_after_use->get_fileline() << ": : "
|
||||
"A symbol with that name was declared here. "
|
||||
"Check for declaration after use." << endl;
|
||||
}
|
||||
des->errors++;
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -5016,6 +5021,11 @@ NetExpr* PEIdent::elaborate_expr_(Design*des, NetScope*scope,
|
|||
<< "' is being used as a constant function, so may "
|
||||
"only reference local variables." << endl;
|
||||
}
|
||||
if (sr.decl_after_use) {
|
||||
cerr << sr.decl_after_use->get_fileline() << ": : "
|
||||
"A symbol with that name was declared here. "
|
||||
"Check for declaration after use." << endl;
|
||||
}
|
||||
des->errors += 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,6 +193,11 @@ NetAssign_* PEIdent::elaborate_lval(Design*des,
|
|||
cerr << get_fileline() << ": error: Could not find variable ``"
|
||||
<< path_ << "'' in ``" << scope_path(scope) <<
|
||||
"''" << endl;
|
||||
if (sr.decl_after_use) {
|
||||
cerr << sr.decl_after_use->get_fileline() << ": : "
|
||||
"A symbol with that name was declared here. "
|
||||
"Check for declaration after use." << endl;
|
||||
}
|
||||
}
|
||||
des->errors += 1;
|
||||
return 0;
|
||||
|
|
|
|||
10
elab_net.cc
10
elab_net.cc
|
|
@ -520,6 +520,11 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
|
|||
if (sig == 0) {
|
||||
cerr << get_fileline() << ": error: Net " << path_
|
||||
<< " is not defined in this context." << endl;
|
||||
if (sr.decl_after_use) {
|
||||
cerr << sr.decl_after_use->get_fileline() << ": : "
|
||||
"A symbol with that name was declared here. "
|
||||
"Check for declaration after use." << endl;
|
||||
}
|
||||
des->errors += 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1117,6 +1122,11 @@ NetNet*PEIdent::elaborate_unpacked_net(Design*des, NetScope*scope) const
|
|||
if (!sr.net) {
|
||||
cerr << get_fileline() << ": error: Net " << path_
|
||||
<< " is not defined in this context." << endl;
|
||||
if (sr.decl_after_use) {
|
||||
cerr << sr.decl_after_use->get_fileline() << ": : "
|
||||
"A symbol with that name was declared here. "
|
||||
"Check for declaration after use." << endl;
|
||||
}
|
||||
des->errors += 1;
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
10
elaborate.cc
10
elaborate.cc
|
|
@ -6041,6 +6041,11 @@ NetProc* PTrigger::elaborate(Design*des, NetScope*scope) const
|
|||
if (!symbol_search(this, des, scope, event_, lexical_pos_, &sr)) {
|
||||
cerr << get_fileline() << ": error: event <" << event_ << ">"
|
||||
<< " not found." << endl;
|
||||
if (sr.decl_after_use) {
|
||||
cerr << sr.decl_after_use->get_fileline() << ": : "
|
||||
"A symbol with that name was declared here. "
|
||||
"Check for declaration after use." << endl;
|
||||
}
|
||||
des->errors += 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -6065,6 +6070,11 @@ NetProc* PNBTrigger::elaborate(Design*des, NetScope*scope) const
|
|||
if (!symbol_search(this, des, scope, event_, lexical_pos_, &sr)) {
|
||||
cerr << get_fileline() << ": error: event <" << event_ << ">"
|
||||
<< " not found." << endl;
|
||||
if (sr.decl_after_use) {
|
||||
cerr << sr.decl_after_use->get_fileline() << ": : "
|
||||
"A symbol with that name was declared here. "
|
||||
"Check for declaration after use." << endl;
|
||||
}
|
||||
des->errors += 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
ivltests/decl_before_use1.v:4: error: Could not find variable ``v'' in ``test''
|
||||
ivltests/decl_before_use1.v:9: : A symbol with that name was declared here. Check for declaration after use.
|
||||
ivltests/decl_before_use1.v:5: error: Unable to bind wire/reg/memory `v' in `test'
|
||||
2 error(s) during elaboration.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
ivltests/decl_before_use2.v:3: error: Net w is not defined in this context.
|
||||
ivltests/decl_before_use2.v:10: : A symbol with that name was declared here. Check for declaration after use.
|
||||
ivltests/decl_before_use2.v:6: error: Unable to bind wire/reg/memory `w' in `test'
|
||||
2 error(s) during elaboration.
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
ivltests/decl_before_use3.v:4: error: event <e> not found.
|
||||
ivltests/decl_before_use3.v:8: : A symbol with that name was declared here. Check for declaration after use.
|
||||
1 error(s) during elaboration.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
ivltests/decl_before_use4.v:4: error: Unable to bind wire/reg/memory `e' in `test'
|
||||
ivltests/decl_before_use4.v:8: : A symbol with that name was declared here. Check for declaration after use.
|
||||
ivltests/decl_before_use4.v:4: error: Failed to evaluate event expression 'e'.
|
||||
2 error(s) during elaboration.
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ struct symbol_search_results {
|
|||
par_val = 0;
|
||||
type = 0;
|
||||
eve = 0;
|
||||
decl_after_use = 0;
|
||||
}
|
||||
|
||||
inline bool is_scope() const {
|
||||
|
|
@ -78,6 +79,11 @@ struct symbol_search_results {
|
|||
ivl_type_t type;
|
||||
// If this is a named event, ...
|
||||
NetEvent*eve;
|
||||
// If a symbol was located but skipped because its lexical position
|
||||
// is after the lexical position of the name being searched, it is
|
||||
// stored here. If more than one such symbol is found, the first
|
||||
// one is retained.
|
||||
const LineInfo*decl_after_use;
|
||||
|
||||
// Store bread crumbs of the search here. The path_tail is the parts
|
||||
// of the original path that were not found, or are after an object
|
||||
|
|
|
|||
|
|
@ -170,6 +170,8 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
res->type = net->net_type();
|
||||
res->path_head = path;
|
||||
return true;
|
||||
} else if (!res->decl_after_use) {
|
||||
res->decl_after_use = net;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -180,6 +182,8 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
res->eve = eve;
|
||||
res->path_head = path;
|
||||
return true;
|
||||
} else if (!res->decl_after_use) {
|
||||
res->decl_after_use = eve;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -190,6 +194,8 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
res->par_val = par;
|
||||
res->path_head = path;
|
||||
return true;
|
||||
} else if (!res->decl_after_use) {
|
||||
res->decl_after_use = par;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue