diff --git a/src/V3Task.cpp b/src/V3Task.cpp index a37cc1c6e..9be0ce8c3 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -1114,7 +1114,7 @@ private: "other than a single 'logic' (IEEE 1800-2017 35.5.5)"); } } - } else { + } else if (nodep->taskPublic()) { if (portp->isWide()) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: Public functions with return > 64 bits wide.\n" diff --git a/test_regress/t/t_class_method_struct.pl b/test_regress/t/t_class_method_struct.pl new file mode 100755 index 000000000..aabcde63e --- /dev/null +++ b/test_regress/t/t_class_method_struct.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_method_struct.v b/test_regress/t/t_class_method_struct.v new file mode 100644 index 000000000..5282df207 --- /dev/null +++ b/test_regress/t/t_class_method_struct.v @@ -0,0 +1,34 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2023 by Antmicro Ltd. +// SPDX-License-Identifier: CC0-1.0 + +typedef struct packed { + int x; + int y; + int z; +} my_struct; + +class Cls; + function my_struct get_struct; + my_struct s; + s.x = 1; + s.y = 2; + s.z = 3; + return s; + endfunction +endclass : Cls + +module t (/*AUTOARG*/); + initial begin + Cls c = new; + my_struct s = c.get_struct; + if (s.x != 1) $stop; + if (s.y != 2) $stop; + if (s.z != 3) $stop; + + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule