Add support for -Wunused warnings.

This commit is contained in:
steve 2006-06-12 00:16:50 +00:00
parent ec510071f1
commit 35e5cea9df
8 changed files with 72 additions and 86 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: compiler.h,v 1.26.2.2 2006/04/23 04:25:45 steve Exp $"
#ident "$Id: compiler.h,v 1.26.2.3 2006/06/12 00:16:50 steve Exp $"
#endif
# include <list>
@ -78,6 +78,9 @@ extern bool warn_timescale;
/* Warn about legal but questionable module port bindings. */
extern bool warn_portbinding;
/* Warn about unused or unassigned variables. */
extern bool warn_unused;
/* This is true if verbose output is requested. */
extern bool verbose_flag;
@ -138,6 +141,9 @@ extern int load_sys_func_table(const char*path);
/*
* $Log: compiler.h,v $
* Revision 1.26.2.3 2006/06/12 00:16:50 steve
* Add support for -Wunused warnings.
*
* Revision 1.26.2.2 2006/04/23 04:25:45 steve
* Add cprop debugging.
*

View File

@ -1,4 +1,4 @@
.TH iverilog 1 "$Date: 2004/10/04 01:10:56 $" Version "$Date: 2004/10/04 01:10:56 $"
.TH iverilog 1 "$Date: 2006/06/12 00:16:53 $" Version "$Date: 2006/06/12 00:16:53 $"
.SH NAME
iverilog - Icarus Verilog compiler
@ -212,6 +212,12 @@ inherit timescale from another file. Both probably mean that
timescales are inconsistent, and simulation timing can be confusing
and dependent on compilation order.
.TP 8
.B unused
This enables warnings for unused variables. This may detect variables
that are not assigned, or variables and nets that are not used, or
similar possible misuses of variables and nets.
.SH "SYSTEM FUNCTION TABLE FILES"
If the source file name as a \fB.sft\fP suffix, then it is taken to be
a system function table file. A System function table file is used to

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: main.c,v 1.65.2.1 2006/03/26 21:47:26 steve Exp $"
#ident "$Id: main.c,v 1.65.2.2 2006/06/12 00:16:53 steve Exp $"
#endif
# include "config.h"
@ -295,7 +295,7 @@ static int t_default(char*cmd, unsigned ncmd)
static void process_warning_switch(const char*name)
{
if (strcmp(name,"all") == 0) {
strcat(warning_flags, "ipt");
strcat(warning_flags, "iptu");
} else if (strcmp(name,"implicit") == 0) {
if (! strchr(warning_flags+2, 'i'))
@ -306,6 +306,9 @@ static void process_warning_switch(const char*name)
} else if (strcmp(name,"timescale") == 0) {
if (! strchr(warning_flags+2, 't'))
strcat(warning_flags, "t");
} else if (strcmp(name,"unused") == 0) {
if (! strchr(warning_flags+2, 'u'))
strcat(warning_flags, "u");
} else if (strcmp(name,"no-implicit") == 0) {
char*cp = strchr(warning_flags+2, 'i');
if (cp) while (*cp) {
@ -324,6 +327,12 @@ static void process_warning_switch(const char*name)
cp[0] = cp[1];
cp += 1;
}
} else if (strcmp(name,"no-unused") == 0) {
char*cp = strchr(warning_flags+2, 'u');
if (cp) while (*cp) {
cp[0] = cp[1];
cp += 1;
}
}
}
@ -778,6 +787,9 @@ int main(int argc, char **argv)
/*
* $Log: main.c,v $
* Revision 1.65.2.2 2006/06/12 00:16:53 steve
* Add support for -Wunused warnings.
*
* Revision 1.65.2.1 2006/03/26 21:47:26 steve
* More installation directory flexibility.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: dup_expr.cc,v 1.18 2004/06/17 16:06:18 steve Exp $"
#ident "$Id: dup_expr.cc,v 1.18.2.1 2006/06/12 00:16:50 steve Exp $"
#endif
# include "config.h"
@ -90,6 +90,7 @@ NetESignal* NetESignal::dup_expr() const
NetESignal*tmp = new NetESignal(net_, msi_, lsi_);
assert(tmp);
tmp->expr_width(expr_width());
tmp->set_line(*this);
return tmp;
}
@ -143,6 +144,9 @@ NetEVariable* NetEVariable::dup_expr() const
/*
* $Log: dup_expr.cc,v $
* Revision 1.18.2.1 2006/06/12 00:16:50 steve
* Add support for -Wunused warnings.
*
* Revision 1.18 2004/06/17 16:06:18 steve
* Help system function signedness survive elaboration.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: elab_expr.cc,v 1.91 2004/10/04 01:10:52 steve Exp $"
#ident "$Id: elab_expr.cc,v 1.91.2.1 2006/06/12 00:16:50 steve Exp $"
#endif
# include "config.h"
@ -742,6 +742,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
}
NetESignal*node = new NetESignal(net);
node->set_line(*this);
assert(idx_ == 0);
// Non-constant bit select? punt and make a subsignal
@ -1005,6 +1006,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
/*
* $Log: elab_expr.cc,v $
* Revision 1.91.2.1 2006/06/12 00:16:50 steve
* Add support for -Wunused warnings.
*
* Revision 1.91 2004/10/04 01:10:52 steve
* Clean up spurious trailing white space.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: elaborate.cc,v 1.308.2.2 2005/12/10 03:30:50 steve Exp $"
#ident "$Id: elaborate.cc,v 1.308.2.3 2006/06/12 00:16:51 steve Exp $"
#endif
# include "config.h"
@ -1179,6 +1179,7 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
tmp->set_line(*this);
NetESignal*sig = new NetESignal(tmp);
sig->set_line(*this);
/* Generate an assignment of the l-value to the temporary... */
string n = scope->local_hsymbol();
@ -1715,6 +1716,7 @@ NetProc* PCallTask::elaborate_usr(Design*des, NetScope*scope) const
continue;
NetESignal*sig = new NetESignal(port);
sig->set_line(*this);
/* Generate the assignment statement. */
NetAssign*ass = new NetAssign(lv, sig);
@ -2783,6 +2785,9 @@ Design* elaborate(list<perm_string>roots)
/*
* $Log: elaborate.cc,v $
* Revision 1.308.2.3 2006/06/12 00:16:51 steve
* Add support for -Wunused warnings.
*
* Revision 1.308.2.2 2005/12/10 03:30:50 steve
* Fix crash on block with assignments that assign lval to self.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: expr_synth.cc,v 1.59.2.5 2006/05/15 03:55:22 steve Exp $"
#ident "$Id: expr_synth.cc,v 1.59.2.6 2006/06/12 00:16:52 steve Exp $"
#endif
# include "config.h"
@ -913,6 +913,21 @@ NetNet* NetETernary::synthesize(Design *des)
*/
NetNet* NetESignal::synthesize(Design*des)
{
if (warn_unused) {
if (net_->peek_lref() == 0 && net_->type()==NetNet::REG) {
cerr << get_line() << ": warning: "
<< "reg " << net_->name()
<< " is used by logic but never assigned." << endl;
}
if (net_->peek_lref() == 0 && net_->type()==NetNet::INTEGER) {
cerr << get_line() << ": warning: "
<< "reg " << net_->name()
<< " is used by logic but never assigned." << endl;
}
}
/* If there is no part select, then the synthesis is trivial. */
if ((lsi_ == 0) && (msi_ == (net_->pin_count() - 1)))
return net_;
@ -925,6 +940,7 @@ NetNet* NetESignal::synthesize(Design*des)
perm_string name = scope->local_symbol();
NetNet*tmp = new NetNet(scope, name, NetNet::WIRE, wid);
tmp->local_flag(true);
tmp->set_line(*this);
for (unsigned idx = 0 ; idx < wid ; idx += 1)
connect(tmp->pin(idx), net_->pin(idx+lsi_));
@ -934,6 +950,9 @@ NetNet* NetESignal::synthesize(Design*des)
/*
* $Log: expr_synth.cc,v $
* Revision 1.59.2.6 2006/06/12 00:16:52 steve
* Add support for -Wunused warnings.
*
* Revision 1.59.2.5 2006/05/15 03:55:22 steve
* Fix synthesis of expressions with land of vectors.
*
@ -957,82 +976,5 @@ NetNet* NetESignal::synthesize(Design*des)
*
* Revision 1.57 2004/06/12 15:00:02 steve
* Support / and % in synthesized contexts.
*
* Revision 1.56 2004/06/01 01:04:57 steve
* Fix synthesis method for logical and/or
*
* Revision 1.55 2004/02/20 18:53:35 steve
* Addtrbute keys are perm_strings.
*
* Revision 1.54 2004/02/18 17:11:56 steve
* Use perm_strings for named langiage items.
*
* Revision 1.53 2004/02/15 04:23:48 steve
* Fix evaluation of compare to constant expression.
*
* Revision 1.52 2003/11/10 19:39:20 steve
* Remove redundant scope tokens.
*
* Revision 1.51 2003/10/27 06:04:21 steve
* More flexible width handling for synthesized add.
*
* Revision 1.50 2003/09/26 02:44:27 steve
* Assure ternary arguments are wide enough.
*
* Revision 1.49 2003/09/03 23:31:36 steve
* Support synthesis of constant downshifts.
*
* Revision 1.48 2003/08/28 04:11:18 steve
* Spelling patch.
*
* Revision 1.47 2003/08/09 03:23:40 steve
* Add support for IVL_LPM_MULT device.
*
* Revision 1.46 2003/07/26 03:34:42 steve
* Start handling pad of expressions in code generators.
*
* Revision 1.45 2003/06/24 01:38:02 steve
* Various warnings fixed.
*
* Revision 1.44 2003/04/19 04:52:56 steve
* Less picky about expression widths while synthesizing ternary.
*
* Revision 1.43 2003/04/08 05:07:15 steve
* Detect constant shift distances in synthesis.
*
* Revision 1.42 2003/04/08 04:33:55 steve
* Synthesize shift expressions.
*
* Revision 1.41 2003/03/06 00:28:41 steve
* All NetObj objects have lex_string base names.
*
* Revision 1.40 2003/02/26 01:29:24 steve
* LPM objects store only their base names.
*
* Revision 1.39 2003/01/30 16:23:07 steve
* Spelling fixes.
*
* Revision 1.38 2003/01/26 21:15:58 steve
* Rework expression parsing and elaboration to
* accommodate real/realtime values and expressions.
*
* Revision 1.37 2002/11/17 23:37:55 steve
* Magnitude compare to 0.
*
* Revision 1.36 2002/08/12 01:34:59 steve
* conditional ident string using autoconfig.
*
* Revision 1.35 2002/07/07 22:31:39 steve
* Smart synthesis of binary AND expressions.
*
* Revision 1.34 2002/07/05 21:26:17 steve
* Avoid emitting to vvp local net symbols.
*
* Revision 1.33 2002/05/26 01:39:02 steve
* Carry Verilog 2001 attributes with processes,
* all the way through to the ivl_target API.
*
* Divide signal reference counts between rval
* and lval references.
*/

View File

@ -19,7 +19,7 @@ const char COPYRIGHT[] =
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: main.cc,v 1.86.2.2 2006/04/23 04:25:45 steve Exp $"
#ident "$Id: main.cc,v 1.86.2.3 2006/06/12 00:16:53 steve Exp $"
#endif
# include "config.h"
@ -103,6 +103,7 @@ FILE *depend_file = NULL;
bool warn_implicit = false;
bool warn_timescale = false;
bool warn_portbinding = false;
bool warn_unused = false;
bool error_implicit = false;
@ -385,6 +386,9 @@ static void read_iconfig_file(const char*ipath)
case 't':
warn_timescale = true;
break;
case 'u':
warn_unused = true;
break;
default:
break;
}
@ -753,6 +757,9 @@ int main(int argc, char*argv[])
/*
* $Log: main.cc,v $
* Revision 1.86.2.3 2006/06/12 00:16:53 steve
* Add support for -Wunused warnings.
*
* Revision 1.86.2.2 2006/04/23 04:25:45 steve
* Add cprop debugging.
*