diff --git a/Changes b/Changes index 7ae45eb62..3a9fc7aba 100644 --- a/Changes +++ b/Changes @@ -48,6 +48,7 @@ Verilator 5.011 devel * Fix missing assignment for wide unpacked structs (#4233). [Jiamin Zhu] * Fix detection of wire/reg duplicates. * Fix false IMPLICITSTATIC on package functions. +* Fix method calls on function return values. Verilator 5.010 2023-04-30 diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index d6a5121f2..9a922fc2c 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -3040,6 +3040,10 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); return; + } else if (m_ds.m_dotp && m_ds.m_dotPos == DP_SCOPE) { + // HERE function() . method_called_on_function_return_value() + m_ds.m_dotPos = DP_MEMBER; + m_ds.m_dotText = ""; } else { checkNoDot(nodep); } diff --git a/test_regress/t/t_class_func_dot.pl b/test_regress/t/t_class_func_dot.pl new file mode 100755 index 000000000..aabcde63e --- /dev/null +++ b/test_regress/t/t_class_func_dot.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 2020 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_func_dot.v b/test_regress/t/t_class_func_dot.v new file mode 100644 index 000000000..4844009a0 --- /dev/null +++ b/test_regress/t/t_class_func_dot.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 Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +class Cls_report_object; + string m_msg; + function string get_msg; + return m_msg; + endfunction +endclass + +function Cls_report_object get_report_object; + Cls_report_object c; + c = new; + c.m_msg = "hello"; + return c; +endfunction + +module t (/*AUTOARG*/); + + string s; + + initial begin + Cls_report_object _local_report_object; + s = get_report_object().get_msg(); + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule