From 444020f7c763d2d00b670fceba46813fab521553 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 7 May 2023 16:47:34 -0400 Subject: [PATCH] Fix super.new missing data type (#4147). --- Changes | 1 + src/V3Width.cpp | 4 +++- test_regress/t/t_class_super_new2.pl | 21 +++++++++++++++++++ test_regress/t/t_class_super_new2.v | 31 ++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100755 test_regress/t/t_class_super_new2.pl create mode 100644 test_regress/t/t_class_super_new2.v diff --git a/Changes b/Changes index c60a56374..ab0807c71 100644 --- a/Changes +++ b/Changes @@ -29,6 +29,7 @@ Verilator 5.011 devel * Fix crash caused by $display() optimization (#4165) (#4166). [Tudor Timi] * Fix arrays of unpacked structs (#4173). [Risto Pejašinović] * Fix $fscanf of decimals overflowing variables (#4174). [Ahmed El-Mahmoudy] +* Fix super.new missing data type (#4147). [Tudor Timi] * Fix detection of wire/reg duplicates. * Fix false IMPLICITSTATIC on package functions. diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 09f34f325..fec2ab39b 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -3755,7 +3755,9 @@ private: void visit(AstNew* nodep) override { if (nodep->didWidth()) return; AstClass* classp = nullptr; + bool assign = false; if (VN_IS(nodep->backp(), Assign)) { // assignment case + assign = true; AstClassRefDType* const refp = m_vup ? VN_CAST(m_vup->dtypeNullSkipRefp(), ClassRefDType) : nullptr; if (!refp) { // e.g. int a = new; @@ -3783,9 +3785,9 @@ private: classp = VN_CAST(nodep->classOrPackagep(), Class); UASSERT_OBJ(classp, nodep, "Unlinked classOrPackagep()"); UASSERT_OBJ(nodep->taskp(), nodep, "Unlinked taskp()"); - nodep->dtypeFrom(nodep->taskp()); } userIterate(nodep->taskp(), nullptr); + if (!assign) nodep->dtypeFrom(nodep->taskp()); processFTaskRefArgs(nodep); } void visit(AstNewCopy* nodep) override { diff --git a/test_regress/t/t_class_super_new2.pl b/test_regress/t/t_class_super_new2.pl new file mode 100755 index 000000000..859050d63 --- /dev/null +++ b/test_regress/t/t_class_super_new2.pl @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2023 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 + +scenarios(simulator => 1); + +compile( + ); + +execute( + check_finished => 1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_class_super_new2.v b/test_regress/t/t_class_super_new2.v new file mode 100644 index 000000000..95a01b683 --- /dev/null +++ b/test_regress/t/t_class_super_new2.v @@ -0,0 +1,31 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2023 by Tudor Timi. +// SPDX-License-Identifier: CC0-1.0 + +class svunit_base; + function new(string name); + endfunction +endclass + +class svunit_testcase extends svunit_base; + function new(string name); + super.new(name); + endfunction +endclass + +module dut_unit_test; + svunit_testcase svunit_ut = new("dut_ut"); +endmodule + +module t(/*AUTOARG*/); + + dut_unit_test dut_ut(); + + initial begin + $write("*-* All Finished *-*\n"); + $finish; + end + +endmodule