From ef814a9ef4f39c0fe9f7a7a7abf39d430e4f74d4 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. Cherry-picked from e576e1eb2cd4a3c23dbc8a3d554c562906441091 --- 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 934344b74..4f8bc67d6 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 e1237b5da..e40ddbf76 100644 --- a/driver/iverilog.man +++ b/driver/iverilog.man @@ -254,7 +254,8 @@ after a \fB-Wall\fP argument to suppress isolated warning types. .TP 8 .B all -This enables all supported warning categories. +This enables the implicit, portbind, select-range and timescale warning +categories. .TP 8 .B implicit @@ -268,6 +269,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 131157841..a8968f64d 100644 --- a/driver/main.c +++ b/driver/main.c @@ -469,6 +469,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')) @@ -476,6 +477,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"); @@ -496,6 +500,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 c80b2baed..c792d1dcb 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;