Add warning class -Wno-declaration-after-use
With `-ggno-strict-parameter-declaration` a warning is issued for parameter use before declaration. This warning suppressed with the new class `-Wno-declaration-after-use`, instead of `-Wno-anachronisms`.
This commit is contained in:
parent
42f7d3a922
commit
54f17a2cb1
|
|
@ -136,7 +136,7 @@ These flags affect the general behavior of the compiler.
|
|||
The standards requires that parameters must be declared lexically
|
||||
before they are used. Using -gno-strict-parameter-declaration
|
||||
will allow using a parameter before declaration, with a
|
||||
warning. The warning can be suppressed with -Wno-anachronisms.
|
||||
warning. The warning can be suppressed with -Wno-declaration-after-use.
|
||||
|
||||
* shared-loop-index/no-shared-loop-index
|
||||
|
||||
|
|
@ -267,6 +267,7 @@ These flags affect the general behavior of the compiler.
|
|||
-Wanachronisms
|
||||
-Wimplicit
|
||||
-Wimplicit-dimensions
|
||||
-Wdeclaration-after-use
|
||||
-Wmacro-replacement
|
||||
-Wportbind
|
||||
-Wselect-range
|
||||
|
|
@ -295,6 +296,11 @@ These flags affect the general behavior of the compiler.
|
|||
This flag is supported in release 10.1 or master branch snapshots after
|
||||
2016-02-06.
|
||||
|
||||
* declaration-after-use
|
||||
|
||||
With -gno-strict-parameter-declaration, issue a warning when a
|
||||
parameter is declared after it is used.
|
||||
|
||||
* macro-redefinition
|
||||
|
||||
This enables warnings when a macro is redefined, even if the macro text
|
||||
|
|
|
|||
|
|
@ -104,6 +104,9 @@ extern bool warn_sens_entire_arr;
|
|||
/* Warn about level-appropriate anachronisms. */
|
||||
extern bool warn_anachronisms;
|
||||
|
||||
/* Warn about declaration after use (unless flaged as errors). */
|
||||
extern bool warn_decl_after_use;
|
||||
|
||||
/* Warn about nets that are references but not driven. */
|
||||
extern bool warn_floating_nets;
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ numbers are not truncated to integer width.
|
|||
The standards requires that parameters must be declared lexically
|
||||
before they are used. Using \fB\-gno\-strict\-parameter\-declaration\fP
|
||||
will allow using a parameter before declaration, with a warning.
|
||||
The warning can be suppressed with -Wno-anachronisms.
|
||||
The warning can be suppressed with -Wno-declaration-after-use.
|
||||
.TP 8
|
||||
.B -gshared-loop-index\fI|\fP-gno-shared-loop-index
|
||||
Enable (default) or disable the exclusion of for-loop control variables
|
||||
|
|
@ -373,6 +373,11 @@ This enables warnings for creation of implicit declarations. For
|
|||
example, if a scalar wire X is used but not declared in the Verilog
|
||||
source, this will print a warning at its first use.
|
||||
|
||||
.TP 8
|
||||
.B declaration-after-use
|
||||
This enables warnings for declarations after use, when
|
||||
those are not flagged as errors (default).
|
||||
|
||||
.TP 8
|
||||
.B macro-redefinition\fI | \fPmacro-replacement
|
||||
This enables preprocessor warnings when a macro is being redefined.
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ int gen_std_include = 1;
|
|||
of the include list. */
|
||||
int gen_relative_include = 0;
|
||||
|
||||
char warning_flags[17] = "n";
|
||||
char warning_flags[18] = "nu";
|
||||
|
||||
int separate_compilation_flag = 0;
|
||||
|
||||
|
|
@ -528,6 +528,7 @@ static void process_warning_switch(const char*name)
|
|||
{
|
||||
if (strcmp(name,"all") == 0) {
|
||||
process_warning_switch("anachronisms");
|
||||
process_warning_switch("declaration-after-use");
|
||||
process_warning_switch("implicit");
|
||||
process_warning_switch("implicit-dimensions");
|
||||
process_warning_switch("macro-replacement");
|
||||
|
|
@ -538,6 +539,9 @@ static void process_warning_switch(const char*name)
|
|||
} else if (strcmp(name,"anachronisms") == 0) {
|
||||
if (! strchr(warning_flags, 'n'))
|
||||
strcat(warning_flags, "n");
|
||||
} else if (strcmp(name,"declaration-after-use") == 0) {
|
||||
if (! strchr(warning_flags, 'u'))
|
||||
strcat(warning_flags, "u");
|
||||
} else if (strcmp(name,"floating-nets") == 0) {
|
||||
if (! strchr(warning_flags, 'f'))
|
||||
strcat(warning_flags, "f");
|
||||
|
|
@ -579,6 +583,12 @@ static void process_warning_switch(const char*name)
|
|||
cp[0] = cp[1];
|
||||
cp += 1;
|
||||
}
|
||||
} else if (strcmp(name,"no-declaration-after-use") == 0) {
|
||||
char*cp = strchr(warning_flags, 'u');
|
||||
if (cp) while (*cp) {
|
||||
cp[0] = cp[1];
|
||||
cp += 1;
|
||||
}
|
||||
} else if (strcmp(name,"no-floating-nets") == 0) {
|
||||
char*cp = strchr(warning_flags, 'f');
|
||||
if (cp) while (*cp) {
|
||||
|
|
|
|||
4
main.cc
4
main.cc
|
|
@ -173,6 +173,7 @@ bool warn_ob_select = false;
|
|||
bool warn_sens_entire_vec = false;
|
||||
bool warn_sens_entire_arr = false;
|
||||
bool warn_anachronisms = false;
|
||||
bool warn_decl_after_use = false;
|
||||
bool warn_floating_nets = false;
|
||||
|
||||
/*
|
||||
|
|
@ -767,6 +768,9 @@ static void read_iconfig_file(const char*ipath)
|
|||
case 'n':
|
||||
warn_anachronisms = true;
|
||||
break;
|
||||
case 'u':
|
||||
warn_decl_after_use = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
res->scope = scope;
|
||||
res->par_val = par;
|
||||
res->path_head = path;
|
||||
if (warn_anachronisms && decl_after_use) {
|
||||
if (warn_decl_after_use && decl_after_use) {
|
||||
cerr << li->get_fileline()
|
||||
<< ": warning: parameter `" << path_tail.name
|
||||
<< "` used before declaration." << endl;
|
||||
|
|
|
|||
Loading…
Reference in New Issue