From fd9f5ab34e7ea38692b76cfea8cea44a5e645fee Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 4 Oct 2024 05:38:36 -0400 Subject: [PATCH] Fix not reporting class reference with extra parameters (#5467). --- Changes | 1 + src/V3LinkDot.cpp | 1 + test_regress/t/t_class_param_extra_bad.out | 11 +++++++++++ test_regress/t/t_class_param_extra_bad.py | 16 ++++++++++++++++ test_regress/t/t_class_param_extra_bad.v | 15 +++++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 test_regress/t/t_class_param_extra_bad.out create mode 100755 test_regress/t/t_class_param_extra_bad.py create mode 100644 test_regress/t/t_class_param_extra_bad.v diff --git a/Changes b/Changes index b3e10fc57..f47b8eac7 100644 --- a/Changes +++ b/Changes @@ -63,6 +63,7 @@ Verilator 5.029 devel * Fix foreach colliding index names (#5444). [Arkadiusz Kozdra, Antmicro Ltd.] * Fix fault on defparam with UNSUPPORTED ignored (#5450). [Luiza de Melo] * Fix class reference with pin that is a class reference (#5454). +* Fix not reporting class reference with extra parameters (#5467). * Fix user-type parameter overlap (#5469). [Todd Strader] * Fix tracing when name() is empty (#5470). [Sam Shahrestani] * Fix timing mode not exiting on empty events (#5472). diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 90c3d11b4..4a1150aac 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -3943,6 +3943,7 @@ class LinkDotResolveVisitor final : public VNVisitor { UINFO(5, indent() << "visit " << nodep << endl); if (AstNode* const cpackagep = nodep->classOrPackageOpp()) { if (AstClassOrPackageRef* const cpackagerefp = VN_CAST(cpackagep, ClassOrPackageRef)) { + iterate(cpackagerefp); const AstClass* const clsp = VN_CAST(cpackagerefp->classOrPackageNodep(), Class); if (clsp && clsp->isParameterized()) { // Unable to link before the instantiation of parameter classes. diff --git a/test_regress/t/t_class_param_extra_bad.out b/test_regress/t/t_class_param_extra_bad.out new file mode 100644 index 000000000..65b1d443e --- /dev/null +++ b/test_regress/t/t_class_param_extra_bad.out @@ -0,0 +1,11 @@ +%Error-PINNOTFOUND: t/t_class_param_extra_bad.v:13:21: Parameter not found: '__paramNumber1' + 13 | localparam Cls1#(123, integer, "text")::bool_t PARAM = 1; + | ^~~ + ... For error description see https://verilator.org/warn/PINNOTFOUND?v=latest +%Error-PINNOTFOUND: t/t_class_param_extra_bad.v:13:26: Parameter not found: '__paramNumber2' + 13 | localparam Cls1#(123, integer, "text")::bool_t PARAM = 1; + | ^~~~~~~ +%Error-PINNOTFOUND: t/t_class_param_extra_bad.v:13:35: Parameter not found: '__paramNumber3' + 13 | localparam Cls1#(123, integer, "text")::bool_t PARAM = 1; + | ^~~~~~ +%Error: Exiting due to diff --git a/test_regress/t/t_class_param_extra_bad.py b/test_regress/t/t_class_param_extra_bad.py new file mode 100755 index 000000000..31228c9a7 --- /dev/null +++ b/test_regress/t/t_class_param_extra_bad.py @@ -0,0 +1,16 @@ +#!/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('linter') + +test.lint(fails=True, expect_filename=test.golden_filename) + +test.passes() diff --git a/test_regress/t/t_class_param_extra_bad.v b/test_regress/t/t_class_param_extra_bad.v new file mode 100644 index 000000000..378c39ebe --- /dev/null +++ b/test_regress/t/t_class_param_extra_bad.v @@ -0,0 +1,15 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2024 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t; + + class Cls1; + typedef bit bool_t; + endclass + + localparam Cls1#(123, integer, "text")::bool_t PARAM = 1; + +endmodule