mirror of
https://github.com/verilator/verilator.git
synced 2024-12-29 10:47:34 +00:00
Improve error when no parameter type value (#5645 partial)
This commit is contained in:
parent
7a8f71e7d8
commit
d165671225
@ -924,13 +924,15 @@ class ParamProcessor final {
|
||||
for (auto* stmtp = srcModpr->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
|
||||
if (AstParamTypeDType* dtypep = VN_CAST(stmtp, ParamTypeDType)) {
|
||||
if (VN_IS(dtypep->subDTypep(), VoidDType)) {
|
||||
nodep->v3error("Missing type parameter: " << dtypep->prettyNameQ());
|
||||
nodep->v3error(
|
||||
"Class parameter type without default value is never given value"
|
||||
<< " (IEEE 1800-2023 6.20.1): " << dtypep->prettyNameQ());
|
||||
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
|
||||
}
|
||||
}
|
||||
if (AstVar* const varp = VN_CAST(stmtp, Var)) {
|
||||
if (VN_IS(srcModpr, Class) && varp->isParam() && !varp->valuep()) {
|
||||
nodep->v3error("Class parameter without initial value is never given value"
|
||||
nodep->v3error("Class parameter without default value is never given value"
|
||||
<< " (IEEE 1800-2023 6.20.1): " << varp->prettyNameQ());
|
||||
}
|
||||
}
|
||||
@ -1200,13 +1202,20 @@ class ParamVisitor final : public VNVisitor {
|
||||
iterateChildren(nodep);
|
||||
if (nodep->isParam()) {
|
||||
if (!nodep->valuep() && !VN_IS(m_modp, Class)) {
|
||||
nodep->v3error("Parameter without initial value is never given value"
|
||||
nodep->v3error("Parameter without default value is never given value"
|
||||
<< " (IEEE 1800-2023 6.20.1): " << nodep->prettyNameQ());
|
||||
} else {
|
||||
V3Const::constifyParamsEdit(nodep); // The variable, not just the var->init()
|
||||
}
|
||||
}
|
||||
}
|
||||
void visit(AstParamTypeDType* nodep) override {
|
||||
iterateChildren(nodep);
|
||||
if (VN_IS(nodep->subDTypep(), VoidDType)) {
|
||||
nodep->v3error("Parameter type without default value is never given value"
|
||||
<< " (IEEE 1800-2023 6.20.1): " << nodep->prettyNameQ());
|
||||
}
|
||||
}
|
||||
// Make sure varrefs cause vars to constify before things above
|
||||
void visit(AstVarRef* nodep) override {
|
||||
// Might jump across functions, so beware if ever add a m_funcp
|
||||
|
@ -1,5 +1,9 @@
|
||||
%Error: t/t_class_param_bad2.v:12:4: Missing type parameter: 'PARAMB'
|
||||
%Error: t/t_class_param_bad2.v:12:4: Class parameter type without default value is never given value (IEEE 1800-2023 6.20.1): 'PARAMB'
|
||||
: ... note: In instance 't'
|
||||
12 | Cls c;
|
||||
| ^~~
|
||||
%Error: t/t_class_param_bad2.v:7:18: Parameter type without default value is never given value (IEEE 1800-2023 6.20.1): 'PARAMB'
|
||||
: ... note: In instance 't'
|
||||
7 | class Cls #(type PARAMB);
|
||||
| ^~~~~~
|
||||
%Error: Exiting due to
|
||||
|
@ -1,5 +1,10 @@
|
||||
%Error: t/t_class_param_noinit_bad.v:13:7: Class parameter without initial value is never given value (IEEE 1800-2023 6.20.1): 'B'
|
||||
%Error: t/t_class_param_noinit_bad.v:13:7: Class parameter without default value is never given value (IEEE 1800-2023 6.20.1): 'B'
|
||||
: ... note: In instance 't'
|
||||
13 | Cls #(1) c;
|
||||
| ^~~
|
||||
%Error: Exiting due to
|
||||
%Error: t/t_class_param_noinit_bad.v:13:7: Class parameter type without default value is never given value (IEEE 1800-2023 6.20.1): 'T'
|
||||
: ... note: In instance 't'
|
||||
13 | Cls #(1) c;
|
||||
| ^~~
|
||||
%Error: Verilator internal fault, sorry. Suggest trying --debug --gdbbt
|
||||
%Error: Command Failed
|
||||
|
@ -5,7 +5,7 @@
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
// No init value is legal with classes, as long as not used without the parameter
|
||||
class Cls #(int A, int B);
|
||||
class Cls #(int A, int B, type T);
|
||||
endclass
|
||||
|
||||
module t(/*AUTOARG*/);
|
||||
|
@ -1,4 +1,4 @@
|
||||
%Error: t/t_lint_iface_array_topmodule_bad.v:8:24: Parameter without initial value is never given value (IEEE 1800-2023 6.20.1): 'DW'
|
||||
%Error: t/t_lint_iface_array_topmodule_bad.v:8:24: Parameter without default value is never given value (IEEE 1800-2023 6.20.1): 'DW'
|
||||
: ... note: In instance 't'
|
||||
8 | parameter integer DW
|
||||
| ^~
|
||||
|
@ -1,4 +1,4 @@
|
||||
%Error: t/t_lint_iface_topmodule_bad.v:8:23: Parameter without initial value is never given value (IEEE 1800-2023 6.20.1): 'DW'
|
||||
%Error: t/t_lint_iface_topmodule_bad.v:8:23: Parameter without default value is never given value (IEEE 1800-2023 6.20.1): 'DW'
|
||||
: ... note: In instance 't'
|
||||
8 | parameter integer DW
|
||||
| ^~
|
||||
|
@ -1,4 +1,4 @@
|
||||
%Error: t/t_param_default_bad.v:7:26: Parameter without initial value is never given value (IEEE 1800-2023 6.20.1): 'Foo'
|
||||
%Error: t/t_param_default_bad.v:7:26: Parameter without default value is never given value (IEEE 1800-2023 6.20.1): 'Foo'
|
||||
: ... note: In instance 't.foo'
|
||||
7 | module m #(parameter int Foo);
|
||||
| ^~~
|
||||
|
@ -3,7 +3,7 @@
|
||||
| ^~~
|
||||
... For warning description see https://verilator.org/warn/NEWERSTD?v=latest
|
||||
... Use "/* verilator lint_off NEWERSTD */" and lint_on around source to disable this message.
|
||||
%Error: t/t_param_default_bad.v:7:26: Parameter without initial value is never given value (IEEE 1800-2023 6.20.1): 'Foo'
|
||||
%Error: t/t_param_default_bad.v:7:26: Parameter without default value is never given value (IEEE 1800-2023 6.20.1): 'Foo'
|
||||
: ... note: In instance 't.foo'
|
||||
7 | module m #(parameter int Foo);
|
||||
| ^~~
|
||||
|
@ -1,7 +1,11 @@
|
||||
%Error: t/t_param_noval_bad.v:7:22: Parameter without initial value is never given value (IEEE 1800-2023 6.20.1): 'P'
|
||||
%Error: t/t_param_noval_bad.v:7:22: Parameter without default value is never given value (IEEE 1800-2023 6.20.1): 'P'
|
||||
: ... note: In instance 't'
|
||||
7 | module t #(parameter P);
|
||||
7 | module t #(parameter P, parameter type T);
|
||||
| ^
|
||||
%Error: t/t_param_noval_bad.v:7:40: Parameter type without default value is never given value (IEEE 1800-2023 6.20.1): 'T'
|
||||
: ... note: In instance 't'
|
||||
7 | module t #(parameter P, parameter type T);
|
||||
| ^
|
||||
%Warning-WIDTHTRUNC: t/t_param_noval_bad.v:10:7: Logical operator GENFOR expects 1 bit on the For Test Condition, but For Test Condition's VARREF 'P' generates 32 bits.
|
||||
: ... note: In instance 't'
|
||||
10 | for (j=0; P; j++)
|
||||
|
@ -4,7 +4,7 @@
|
||||
// any use, without warranty, 2019 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t #(parameter P);
|
||||
module t #(parameter P, parameter type T);
|
||||
generate
|
||||
var j;
|
||||
for (j=0; P; j++)
|
||||
|
Loading…
Reference in New Issue
Block a user