From bc3bf6ab5ef7e40feb15f100272edf1917d0b7d2 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 6 May 2025 21:11:34 -0400 Subject: [PATCH] Tests: Add t_param_type_bad3 --- src/V3LinkDot.cpp | 4 ++-- src/V3Param.cpp | 4 ++-- test_regress/t/t_param_type_bad3.out | 5 +++++ test_regress/t/t_param_type_bad3.py | 20 ++++++++++++++++++++ test_regress/t/t_param_type_bad3.v | 10 ++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 test_regress/t/t_param_type_bad3.out create mode 100755 test_regress/t/t_param_type_bad3.py create mode 100644 test_regress/t/t_param_type_bad3.v diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 39e8d4510..5ace4d040 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -3341,8 +3341,8 @@ class LinkDotResolveVisitor final : public VNVisitor { nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - } else if (AstConstraint* const consp = VN_CAST(foundp->nodep(), Constraint)) { - AstNode* const newp = new AstConstraintRef{nodep->fileline(), nullptr, consp}; + } else if (AstConstraint* const defp = VN_CAST(foundp->nodep(), Constraint)) { + AstNode* const newp = new AstConstraintRef{nodep->fileline(), nullptr, defp}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); ok = true; diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 09092af24..bfee3e4fe 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -928,7 +928,7 @@ 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)) { + if (VN_IS(dtypep->skipRefp(), VoidDType)) { nodep->v3error( "Class parameter type without default value is never given value" << " (IEEE 1800-2023 6.20.1): " << dtypep->prettyNameQ()); @@ -1217,7 +1217,7 @@ class ParamVisitor final : public VNVisitor { } void visit(AstParamTypeDType* nodep) override { iterateChildren(nodep); - if (VN_IS(nodep->subDTypep(), VoidDType)) { + if (VN_IS(nodep->skipRefp(), VoidDType)) { nodep->v3error("Parameter type without default value is never given value" << " (IEEE 1800-2023 6.20.1): " << nodep->prettyNameQ()); } diff --git a/test_regress/t/t_param_type_bad3.out b/test_regress/t/t_param_type_bad3.out new file mode 100644 index 000000000..f30889150 --- /dev/null +++ b/test_regress/t/t_param_type_bad3.out @@ -0,0 +1,5 @@ +%Error: t/t_param_type_bad3.v:9:26: Expecting a data type: 'PI' + 9 | localparam type P_T = PI; + | ^~ + ... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance. +%Error: Exiting due to diff --git a/test_regress/t/t_param_type_bad3.py b/test_regress/t/t_param_type_bad3.py new file mode 100755 index 000000000..45bc705e4 --- /dev/null +++ b/test_regress/t/t_param_type_bad3.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2024 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +import vltest_bootstrap + +test.scenarios('vlt') + +test.lint( + # Bug1575 required trace to crash + verilator_flags2=["--trace-vcd"], + fails=True, + expect_filename=test.golden_filename) + +test.passes() diff --git a/test_regress/t/t_param_type_bad3.v b/test_regress/t/t_param_type_bad3.v new file mode 100644 index 000000000..3848e7c9e --- /dev/null +++ b/test_regress/t/t_param_type_bad3.v @@ -0,0 +1,10 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2019 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t; + localparam int PI = 6; + localparam type P_T = PI; // Bad +endmodule