Add the -Wimplicit-dimensions warning.

This commit is contained in:
Stephen Williams 2016-02-06 16:07:50 -08:00
parent 76ced1cf7c
commit f3647578d4
5 changed files with 36 additions and 1 deletions

View File

@ -80,6 +80,10 @@ extern unsigned recursive_mod_limit;
/* Implicit definitions of wires. */ /* Implicit definitions of wires. */
extern bool warn_implicit; extern bool warn_implicit;
/* Warn if dimensions of port or var/net are implicitly taken from
the input/output/inout declaration. */
extern bool warn_implicit_dimensions;
/* inherit timescales across files. */ /* inherit timescales across files. */
extern bool warn_timescale; extern bool warn_timescale;

View File

@ -496,6 +496,7 @@ static void process_warning_switch(const char*name)
if (strcmp(name,"all") == 0) { if (strcmp(name,"all") == 0) {
process_warning_switch("anachronisms"); process_warning_switch("anachronisms");
process_warning_switch("implicit"); process_warning_switch("implicit");
process_warning_switch("implicit-dimensions");
process_warning_switch("portbind"); process_warning_switch("portbind");
process_warning_switch("select-range"); process_warning_switch("select-range");
process_warning_switch("timescale"); process_warning_switch("timescale");
@ -509,6 +510,9 @@ static void process_warning_switch(const char*name)
} else if (strcmp(name,"implicit") == 0) { } else if (strcmp(name,"implicit") == 0) {
if (! strchr(warning_flags, 'i')) if (! strchr(warning_flags, 'i'))
strcat(warning_flags, "i"); strcat(warning_flags, "i");
} else if (strcmp(name,"implicit-dimensions") == 0) {
if (! strchr(warning_flags, 'd'))
strcat(warning_flags, "d");
} else if (strcmp(name,"portbind") == 0) { } else if (strcmp(name,"portbind") == 0) {
if (! strchr(warning_flags, 'p')) if (! strchr(warning_flags, 'p'))
strcat(warning_flags, "p"); strcat(warning_flags, "p");
@ -547,6 +551,12 @@ static void process_warning_switch(const char*name)
cp[0] = cp[1]; cp[0] = cp[1];
cp += 1; cp += 1;
} }
} else if (strcmp(name,"no-implicit-dimensions") == 0) {
char*cp = strchr(warning_flags, 'd');
if (cp) while (*cp) {
cp[0] = cp[1];
cp += 1;
}
} else if (strcmp(name,"no-portbind") == 0) { } else if (strcmp(name,"no-portbind") == 0) {
char*cp = strchr(warning_flags, 'p'); char*cp = strchr(warning_flags, 'p');
if (cp) while (*cp) { if (cp) while (*cp) {

View File

@ -976,6 +976,23 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
} }
if (port_set_ || net_set_) { if (port_set_ || net_set_) {
if (warn_implicit_dimensions
&& port_set_ && net_set_
&& net_.empty() && !port_.empty()) {
cerr << get_fileline() << ": warning: "
<< "var/net declaration of " << basename()
<< " inherits dimensions from port declaration." << endl;
}
if (warn_implicit_dimensions
&& port_set_ && net_set_
&& port_.empty() && net_.empty()) {
cerr << get_fileline() << ": warning: "
<< "Port declaration of " << basename()
<< " inherits dimensions from var/net." << endl;
}
bool bad_range = false; bool bad_range = false;
vector<netrange_t> plist, nlist; vector<netrange_t> plist, nlist;
/* If they exist get the port definition MSB and LSB */ /* If they exist get the port definition MSB and LSB */

View File

@ -153,6 +153,7 @@ FILE *depend_file = NULL;
* These are the warning enable flags. * These are the warning enable flags.
*/ */
bool warn_implicit = false; bool warn_implicit = false;
bool warn_implicit_dimensions = false;
bool warn_timescale = false; bool warn_timescale = false;
bool warn_portbinding = false; bool warn_portbinding = false;
bool warn_inf_loop = false; bool warn_inf_loop = false;
@ -682,6 +683,9 @@ static void read_iconfig_file(const char*ipath)
case 'i': case 'i':
warn_implicit = true; warn_implicit = true;
break; break;
case 'd':
warn_implicit_dimensions = true;
break;
case 'l': case 'l':
warn_inf_loop = true; warn_inf_loop = true;
break; break;

View File

@ -15,7 +15,7 @@ iwidth:32
sys_func:vpi/system.sft sys_func:vpi/system.sft
sys_func:vpi/v2005_math.sft sys_func:vpi/v2005_math.sft
sys_func:vpi/va_math.sft sys_func:vpi/va_math.sft
warnings:afilnpstv warnings:adfilnpstv
debug:eval_tree debug:eval_tree
debug:elaborate debug:elaborate
debug:emit debug:emit