Change strict-net-declaration to strict-net-var-declaration.
Internally the compiler uses 'net' for both nets and variables, but we should make it clear to the user that this option applies to both.
This commit is contained in:
parent
dc0d162fa9
commit
4c315b32d4
|
|
@ -133,16 +133,15 @@ These flags affect the general behavior of the compiler.
|
|||
|
||||
* strict-declaration/no-strict-declaration
|
||||
|
||||
* strict-net-declaration/no-net-strict-declaration
|
||||
* strict-net-var-declaration/no-strict-net-var-declaration
|
||||
|
||||
* strict-parameter-declaration/no-strict-parameter-declaration
|
||||
|
||||
The standards require that nets and parameters must be declared
|
||||
lexically before they are used. Using -gno-strict-declaration
|
||||
will allow using a net or parameter before declaration, with a
|
||||
warning. The warning can be suppressed with
|
||||
-Wno-declaration-after-use. The option can be applied for nets
|
||||
and parameters separately.
|
||||
The standards require that nets, variables, and parameters must be
|
||||
declared lexically before they are used. Using -gno-strict-declaration
|
||||
will allow using a data object before declaration, with a warning. The
|
||||
warning can be suppressed with -Wno-declaration-after-use. The option
|
||||
can be applied for nets and variables and for parameters separately.
|
||||
|
||||
* shared-loop-index/no-shared-loop-index
|
||||
|
||||
|
|
|
|||
10
compiler.h
10
compiler.h
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef IVL_compiler_H
|
||||
#define IVL_compiler_H
|
||||
/*
|
||||
* Copyright (c) 1999-2021 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 1999-2026 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -220,12 +220,12 @@ extern bool gn_shared_loop_index_flag;
|
|||
*/
|
||||
extern bool gn_strict_parameter_declaration;
|
||||
|
||||
/* If this flag is true (default), then nets must be declared before
|
||||
use. `-gno-strict[-net]-declaration` allows to use nets before
|
||||
declaration, as prior to version 13.
|
||||
/* If this flag is true (default), then nets and variablesmust be declared
|
||||
before use. `-gno-strict[-net-var]-declaration` allows to use nets and
|
||||
variables before declaration, as prior to version 13.
|
||||
A warning is emited with -Wdeclaration-after-use (default).
|
||||
*/
|
||||
extern bool gn_strict_net_declaration;
|
||||
extern bool gn_strict_net_var_declaration;
|
||||
|
||||
static inline bool gn_system_verilog(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -152,14 +152,14 @@ numbers are not truncated to integer width.
|
|||
.TP 8
|
||||
.B -gstrict-declaration\fI|\fP-gno-strict-declaration
|
||||
.TP 8
|
||||
.B -gstrict-net-declaration\fI|\fP-gno-strict-net-declaration
|
||||
.B -gstrict-net-var-declaration\fI|\fP-gno-strict-net-var-declaration
|
||||
.TP 8
|
||||
.B -gstrict-parameter-declaration\fI|\fP-gno-strict-parameter-declaration
|
||||
The standards requires that nets and parameters must be declared lexically
|
||||
before they are used. Using \fB\-gno\-strict\-declaration\fP
|
||||
will allow using a parameter before declaration, with a warning.
|
||||
The warning can be suppressed with -Wno-declaration-after-use. The
|
||||
option can be applied for nets and parameters separately.
|
||||
The standards require that nets, variables, and parameters are declared
|
||||
lexically before they are used. Using \fB\-gno\-strict\-declaration\fP
|
||||
will allow using a data object before declaration, with a warning. The
|
||||
warning can be suppressed with -Wno-declaration-after-use. The option
|
||||
can be applied for nets and variables and for parameters separately.
|
||||
.TP 8
|
||||
.B -gshared-loop-index\fI|\fP-gno-shared-loop-index
|
||||
Enable (default) or disable the exclusion of for-loop control variables
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ const char*gen_strict_ca_eval = "no-strict-ca-eval";
|
|||
const char*gen_strict_expr_width = "no-strict-expr-width";
|
||||
const char*gen_shared_loop_index = "shared-loop-index";
|
||||
const char*gen_verilog_ams = "no-verilog-ams";
|
||||
const char*gen_strict_net_declaration = "strict-net-declaration";
|
||||
const char*gen_strict_net_var_declaration = "strict-net-var-declaration";
|
||||
const char*gen_strict_parameter_declaration = "strict-parameter-declaration";
|
||||
|
||||
/* Boolean: true means use a default include dir, false means don't */
|
||||
|
|
@ -828,18 +828,18 @@ static int process_generation(const char*name)
|
|||
gen_verilog_ams = "no-verilog-ams";
|
||||
|
||||
else if (strcmp(name,"strict-declaration") == 0) {
|
||||
gen_strict_net_declaration = "strict-net-declaration";
|
||||
gen_strict_net_var_declaration = "strict-net-var-declaration";
|
||||
gen_strict_parameter_declaration = "strict-parameter-declaration";
|
||||
}
|
||||
else if (strcmp(name,"no-strict-declaration") == 0) {
|
||||
gen_strict_net_declaration = "no-strict-net-declaration";
|
||||
gen_strict_net_var_declaration = "no-strict-net-var-declaration";
|
||||
gen_strict_parameter_declaration = "no-strict-parameter-declaration";
|
||||
}
|
||||
else if (strcmp(name,"strict-net-declaration") == 0)
|
||||
gen_strict_net_declaration = "strict-net-declaration";
|
||||
else if (strcmp(name,"strict-net-var-declaration") == 0)
|
||||
gen_strict_net_var_declaration = "strict-net-var-declaration";
|
||||
|
||||
else if (strcmp(name,"no-strict-net-declaration") == 0)
|
||||
gen_strict_net_declaration = "no-strict-net-declaration";
|
||||
else if (strcmp(name,"no-strict-net-var-declaration") == 0)
|
||||
gen_strict_net_var_declaration = "no-strict-net-var-declaration";
|
||||
|
||||
else if (strcmp(name,"strict-parameter-declaration") == 0)
|
||||
gen_strict_parameter_declaration = "strict-parameter-declaration";
|
||||
|
|
@ -871,7 +871,7 @@ static int process_generation(const char*name)
|
|||
" strict-expr-width | no-strict-expr-width\n"
|
||||
" shared-loop-index | no-shared-loop-index\n"
|
||||
" strict-declaration | no-strict-declaration\n"
|
||||
" [no-]strict-[net|parameter]-declaration\n");
|
||||
" [no-]strict-[net-var|parameter]-declaration\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1419,7 +1419,7 @@ int main(int argc, char **argv)
|
|||
fprintf(iconfig_file, "generation:%s\n", gen_strict_expr_width);
|
||||
fprintf(iconfig_file, "generation:%s\n", gen_shared_loop_index);
|
||||
fprintf(iconfig_file, "generation:%s\n", gen_verilog_ams);
|
||||
fprintf(iconfig_file, "generation:%s\n", gen_strict_net_declaration);
|
||||
fprintf(iconfig_file, "generation:%s\n", gen_strict_net_var_declaration);
|
||||
fprintf(iconfig_file, "generation:%s\n", gen_strict_parameter_declaration);
|
||||
fprintf(iconfig_file, "generation:%s\n", gen_icarus);
|
||||
fprintf(iconfig_file, "warnings:%s\n", warning_flags);
|
||||
|
|
|
|||
10
main.cc
10
main.cc
|
|
@ -118,7 +118,7 @@ bool gn_strict_expr_width_flag = false;
|
|||
bool gn_shared_loop_index_flag = true;
|
||||
bool gn_verilog_ams_flag = false;
|
||||
bool gn_strict_parameter_declaration = true;
|
||||
bool gn_strict_net_declaration = true;
|
||||
bool gn_strict_net_var_declaration = true;
|
||||
|
||||
/*
|
||||
* For some generations we allow a system function to be called
|
||||
|
|
@ -395,11 +395,11 @@ static void process_generation_flag(const char*gen)
|
|||
} else if (strcmp(gen,"no-strict-parameter-declaration") == 0) {
|
||||
gn_strict_parameter_declaration = false;
|
||||
|
||||
} else if (strcmp(gen,"strict-net-declaration") == 0) {
|
||||
gn_strict_net_declaration = true;
|
||||
} else if (strcmp(gen,"strict-net-var-declaration") == 0) {
|
||||
gn_strict_net_var_declaration = true;
|
||||
|
||||
} else if (strcmp(gen,"no-strict-net-declaration") == 0) {
|
||||
gn_strict_net_declaration = false;
|
||||
} else if (strcmp(gen,"no-strict-net-var-declaration") == 0) {
|
||||
gn_strict_net_var_declaration = false;
|
||||
|
||||
} else {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
|
||||
if (NetNet*net = scope->find_signal(path_tail.name)) {
|
||||
bool decl_after_use = !prefix_scope && !(net->lexical_pos() <= lexical_pos);
|
||||
if (!gn_strict_net_declaration || !decl_after_use) {
|
||||
if (!gn_strict_net_var_declaration || !decl_after_use) {
|
||||
path.push_back(path_tail);
|
||||
res->scope = scope;
|
||||
res->net = net;
|
||||
|
|
@ -173,10 +173,10 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
res->path_head = path;
|
||||
if (warn_decl_after_use && decl_after_use) {
|
||||
cerr << li->get_fileline()
|
||||
<< ": warning: net `" << path_tail.name
|
||||
<< ": warning: net/variable `" << path_tail.name
|
||||
<< "` used before declaration." << endl;
|
||||
cerr << net->get_fileline()
|
||||
<< ": : the net is declared here." << endl;
|
||||
<< ": : the net/variable is declared here." << endl;
|
||||
// suppress further warnings for this net
|
||||
net->lexical_pos(lexical_pos);
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
|
||||
if (NetEvent*eve = scope->find_event(path_tail.name)) {
|
||||
bool decl_after_use = !prefix_scope && !(eve->lexical_pos() <= lexical_pos);
|
||||
if (!gn_strict_net_declaration || !decl_after_use) {
|
||||
if (!gn_strict_net_var_declaration || !decl_after_use) {
|
||||
path.push_back(path_tail);
|
||||
res->scope = scope;
|
||||
res->eve = eve;
|
||||
|
|
|
|||
Loading…
Reference in New Issue