diff --git a/Changes b/Changes index 98fdc63f0..3c99e9702 100644 --- a/Changes +++ b/Changes @@ -25,7 +25,7 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix multithreaded yield behavior when no work. [Patrick Stewart] **** Fix bad-syntax crashes, bug1548, bug1550-1553, bug1557-1560, bug1563, - bug1573-1575. [Eric Rippey] + bug1573-1576. [Eric Rippey] **** Benchmark --protect-lib runtime, bug1519. [Todd Strader] diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 980fbdd1c..68d0105ed 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -3478,7 +3478,12 @@ private: UASSERT_OBJ(stage == FINAL, nodep, "Bad state to iterateCheck"); UASSERT_OBJ(underp && underp->dtypep(), nodep, "Node has no type"); // Perhaps forgot to do a prelim visit on it? - if (expDTypep == underp->dtypep()) { // Perfect + if (VN_IS(underp, NodeDType)) { // Note the node itself, not node's data type + // Must be near top of these checks as underp->dtypep() will look normal + underp->v3error(ucfirst(nodep->prettyOperatorName()) + <<" expected non-datatype "<name()<<"' is a datatype."); + } else if (expDTypep == underp->dtypep()) { // Perfect underp = userIterateSubtreeReturnEdits(underp, WidthVP(SELF, FINAL).p()); } else if (expDTypep->isDouble() && underp->isDouble()) { // Also good underp = userIterateSubtreeReturnEdits(underp, WidthVP(SELF, FINAL).p()); @@ -3491,10 +3496,6 @@ private: } else if (expDTypep->isString() && !underp->dtypep()->isString()) { underp = spliceCvtString(underp); underp = userIterateSubtreeReturnEdits(underp, WidthVP(SELF, FINAL).p()); - } else if (VN_IS(underp, NodeDType)) { // Note the node itself, not node's data type - underp->v3error(ucfirst(nodep->prettyOperatorName()) - <<" expected non-datatype "<name()<<"' is a datatype."); } else { AstBasicDType* expBasicp = expDTypep->basicp(); AstBasicDType* underBasicp = underp->dtypep()->basicp(); diff --git a/test_regress/t/t_param_type_bad2.out b/test_regress/t/t_param_type_bad2.out index fa74f0304..481444c92 100644 --- a/test_regress/t/t_param_type_bad2.out +++ b/test_regress/t/t_param_type_bad2.out @@ -1,4 +1,9 @@ -%Error: t/t_param_type_bad2.v:8: Parameter type's initial value isn't a type: 'bad2' - localparam type bad2 = 2; - ^~~~ +%Error: t/t_param_type_bad2.v:7: Operator VAR 't' expected non-datatype Initial value but 'logic' is a datatype. + : ... In instance t + localparam t = logic; + ^~~~~ +%Error: t/t_param_type_bad2.v:8: Operator VAR 't2' expected non-datatype Initial value but 'real' is a datatype. + : ... In instance t + localparam t2 = realtime; + ^~~~~~~~ %Error: Exiting due to diff --git a/test_regress/t/t_param_type_bad2.pl b/test_regress/t/t_param_type_bad2.pl index ef912260b..847928628 100755 --- a/test_regress/t/t_param_type_bad2.pl +++ b/test_regress/t/t_param_type_bad2.pl @@ -9,9 +9,9 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di scenarios(vlt => 1); -lint( +compile( # Bug1575 required trace to crash - verilator_flags2 => ["--trace"], + verilator_flags2 => ["--trace --cc"], fails => 1, expect_filename => $Self->{golden_filename}, ); diff --git a/test_regress/t/t_param_type_bad2.v b/test_regress/t/t_param_type_bad2.v index 686f415c4..36ea92fe5 100644 --- a/test_regress/t/t_param_type_bad2.v +++ b/test_regress/t/t_param_type_bad2.v @@ -4,6 +4,6 @@ // without warranty, 2019 by Wilson Snyder. module t; - localparam type t = logic; // Fine - localparam type bad2 = 2; // Bad + localparam t = logic; // Bad + localparam t2 = realtime; // Bad endmodule