From e576e1eb2cd4a3c23dbc8a3d554c562906441091 Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 25 Aug 2009 10:31:08 -0700 Subject: [PATCH] Add a -Wselect-range warning class. This patch adds support for a -Wselect-range warning class to the driver and ivl programs. This is part of -Wall. The actual checks will be added in a later patch. --- compiler.h | 3 +++ driver/iverilog.man | 9 ++++++++- driver/main.c | 10 ++++++++++ main.cc | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/compiler.h b/compiler.h index 94bf37c2c..a9922baf9 100644 --- a/compiler.h +++ b/compiler.h @@ -82,6 +82,9 @@ extern bool warn_timescale; /* Warn about legal but questionable module port bindings. */ extern bool warn_portbinding; +/* Warn about constant out of bound selects. */ +extern bool warn_ob_select; + /* Warn about structures that may have infinite loops. */ extern bool warn_inf_loop; diff --git a/driver/iverilog.man b/driver/iverilog.man index 8c72c5f86..c81d463eb 100644 --- a/driver/iverilog.man +++ b/driver/iverilog.man @@ -259,7 +259,8 @@ after a \fB-Wall\fP argument to suppress isolated warning types. .TP 8 .B all -This enables the implicit, portbind and timescale warning categories. +This enables the implicit, portbind, select-range and timescale warning +categories. .TP 8 .B implicit @@ -273,6 +274,12 @@ This enables warnings for ports of module instantiations that are not connected but probably should be. Dangling input ports, for example, will generate a warning. +.TP 8 +.B select-range +This enables warnings for constant out of bound selects. This includes +partial or fully out of bound selects as well as a select using 'bx as +an index. + .TP 8 .B timescale This enables warnings for inconsistent use of the timescale diff --git a/driver/main.c b/driver/main.c index c45d837b0..c75eb09c2 100644 --- a/driver/main.c +++ b/driver/main.c @@ -475,6 +475,7 @@ static void process_warning_switch(const char*name) if (strcmp(name,"all") == 0) { process_warning_switch("implicit"); process_warning_switch("portbind"); + process_warning_switch("select-range"); process_warning_switch("timescale"); } else if (strcmp(name,"implicit") == 0) { if (! strchr(warning_flags, 'i')) @@ -482,6 +483,9 @@ static void process_warning_switch(const char*name) } else if (strcmp(name,"portbind") == 0) { if (! strchr(warning_flags, 'p')) strcat(warning_flags, "p"); + } else if (strcmp(name,"select-range") == 0) { + if (! strchr(warning_flags, 's')) + strcat(warning_flags, "s"); } else if (strcmp(name,"timescale") == 0) { if (! strchr(warning_flags, 't')) strcat(warning_flags, "t"); @@ -502,6 +506,12 @@ static void process_warning_switch(const char*name) cp[0] = cp[1]; cp += 1; } + } else if (strcmp(name,"no-select-range") == 0) { + char*cp = strchr(warning_flags, 's'); + if (cp) while (*cp) { + cp[0] = cp[1]; + cp += 1; + } } else if (strcmp(name,"no-timescale") == 0) { char*cp = strchr(warning_flags, 't'); if (cp) while (*cp) { diff --git a/main.cc b/main.cc index 5c58b7a71..9a389708f 100644 --- a/main.cc +++ b/main.cc @@ -115,6 +115,7 @@ bool warn_implicit = false; bool warn_timescale = false; bool warn_portbinding = false; bool warn_inf_loop = false; +bool warn_ob_select = false; bool error_implicit = false; @@ -491,6 +492,9 @@ static void read_iconfig_file(const char*ipath) case 'l': warn_inf_loop = true; break; + case 's': + warn_ob_select = true; + break; case 'p': warn_portbinding = true; break;