Only warn about declaration after use once for each data object.
This commit is contained in:
parent
475f098cab
commit
29e128ed94
10
net_scope.cc
10
net_scope.cc
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2000-2026 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2016 CERN Michele Castellana (michele.castellana@cern.ch)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
|
|
@ -462,6 +462,14 @@ unsigned NetScope::get_parameter_lexical_pos(perm_string key) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
void NetScope::set_parameter_lexical_pos(perm_string key, unsigned lexical_pos)
|
||||
{
|
||||
map<perm_string,param_expr_t>::iterator idx;
|
||||
|
||||
idx = parameters.find(key);
|
||||
if (idx != parameters.end()) idx->second.lexical_pos = lexical_pos;
|
||||
}
|
||||
|
||||
void NetScope::print_type(ostream&stream) const
|
||||
{
|
||||
switch (type_) {
|
||||
|
|
|
|||
|
|
@ -1274,6 +1274,7 @@ class NetScope : public Definitions, public Attrib {
|
|||
LineInfo get_parameter_line_info(perm_string name) const;
|
||||
|
||||
unsigned get_parameter_lexical_pos(perm_string name) const;
|
||||
void set_parameter_lexical_pos(perm_string name, unsigned lexical_pos);
|
||||
|
||||
/* Module instance arrays are collected here for access during
|
||||
the multiple elaboration passes. */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2024 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2003-2026 Stephen Williams (steve@icarus.com)
|
||||
* Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
|
|
@ -175,6 +175,8 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
cerr << li->get_fileline()
|
||||
<< ": warning: net `" << path_tail.name
|
||||
<< "` used before declaration." << endl;
|
||||
// suppress further warnings for this net
|
||||
net->lexical_pos(lexical_pos);
|
||||
}
|
||||
return true;
|
||||
} else if (!res->decl_after_use) {
|
||||
|
|
@ -193,6 +195,8 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
cerr << li->get_fileline()
|
||||
<< ": warning: event `" << path_tail.name
|
||||
<< "` used before declaration." << endl;
|
||||
// suppress further warnings for this event
|
||||
eve->lexical_pos(lexical_pos);
|
||||
}
|
||||
return true;
|
||||
} else if (!res->decl_after_use) {
|
||||
|
|
@ -209,9 +213,11 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
res->par_val = par;
|
||||
res->path_head = path;
|
||||
if (warn_decl_after_use && decl_after_use) {
|
||||
cerr << li->get_fileline()
|
||||
<< ": warning: parameter `" << path_tail.name
|
||||
<< "` used before declaration." << endl;
|
||||
cerr << li->get_fileline()
|
||||
<< ": warning: parameter `" << path_tail.name
|
||||
<< "` used before declaration." << endl;
|
||||
// suppress further warnings for this parameter
|
||||
scope->set_parameter_lexical_pos(path_tail.name, lexical_pos);
|
||||
}
|
||||
return true;
|
||||
} else if (!res->decl_after_use) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue