Skip to content

Commit

Permalink
Add a -Wselect-range warning class.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
caryr authored and steveicarus committed Aug 27, 2009
1 parent ed4e2eb commit e576e1e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions compiler.h
Expand Up @@ -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;

Expand Down
9 changes: 8 additions & 1 deletion driver/iverilog.man
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions driver/main.c
Expand Up @@ -475,13 +475,17 @@ 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'))
strcat(warning_flags, "i");
} 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");
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions main.cc
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e576e1e

Please sign in to comment.