From e422c183fff610233a442a13dc20739241c8dd80 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 26 Jun 2025 18:16:21 -0400 Subject: [PATCH] Fix method calls without parenthesis (#6127). --- Changes | 1 + src/V3LinkDot.cpp | 6 +++++- test_regress/t/t_fallback_bad.out | 6 +++--- test_regress/t/t_func_no_paren.py | 16 ++++++++++++++++ test_regress/t/t_func_no_paren.v | 23 +++++++++++++++++++++++ test_regress/t/t_fuzz_always_bad.out | 2 +- test_regress/t/t_inst_missing_dot_bad.out | 2 +- 7 files changed, 50 insertions(+), 6 deletions(-) create mode 100755 test_regress/t/t_func_no_paren.py create mode 100644 test_regress/t/t_func_no_paren.v diff --git a/Changes b/Changes index 164d9e92a..2da5b8239 100644 --- a/Changes +++ b/Changes @@ -78,6 +78,7 @@ Verilator 5.037 devel * Fix decoding octal string escapes with 1-2 digits (#6108). * Fix colon-divide operator without space (#6121). [Alex Solomatnikov] * Fix variables declared in fork after taskify (#6126). [Kamil Rakoczy, Antmicro Ltd.] +* Fix method calls without parenthesis (#6127). [Alex Solomatnikov] Verilator 5.036 2025-04-27 diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index e93f321e0..9a06cb1b4 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -3123,9 +3123,13 @@ class LinkDotResolveVisitor final : public VNVisitor { expectWhat = "scope/variable"; allowScope = true; allowVar = true; - } else if (m_ds.m_dotPos == DP_NONE || m_ds.m_dotPos == DP_FINAL) { + } else if (m_ds.m_dotPos == DP_NONE) { expectWhat = "variable"; allowVar = true; + } else if (m_ds.m_dotPos == DP_FINAL) { + expectWhat = "variable/method"; + allowFTask = true; + allowVar = true; } else { UINFO(1, "ds=" << m_ds.ascii()); nodep->v3fatalSrc("Unhandled VParseRefExp"); diff --git a/test_regress/t/t_fallback_bad.out b/test_regress/t/t_fallback_bad.out index 0555c5429..6d2ba11ae 100644 --- a/test_regress/t/t_fallback_bad.out +++ b/test_regress/t/t_fallback_bad.out @@ -5,10 +5,10 @@ %Error: t/t_fallback_bad.v:27:15: Can't find definition of task/function: 'tsk' 27 | this.tsk; | ^~~ -%Error: t/t_fallback_bad.v:28:16: Can't find definition of variable: 'f' +%Error: t/t_fallback_bad.v:28:16: Can't find definition of variable/method: 'f' 28 | super.f = 8; | ^ -%Error: t/t_fallback_bad.v:29:15: Can't find definition of variable: 'f' +%Error: t/t_fallback_bad.v:29:15: Can't find definition of variable/method: 'f' 29 | this.f = 8; | ^ %Error: t/t_fallback_bad.v:30:20: Can't find definition of 'tsk' in dotted task/function: 'sub1.sub2.tsk' @@ -21,7 +21,7 @@ %Error: t/t_fallback_bad.v:32:15: Can't find definition of task/function: 'tsk' 32 | pkg::tsk(); | ^~~ -%Error: t/t_fallback_bad.v:33:20: Can't find definition of 'f' in dotted variable: 'sub1.sub2.f' +%Error: t/t_fallback_bad.v:33:20: Can't find definition of 'f' in dotted variable/method: 'sub1.sub2.f' 33 | sub1.sub2.f = 8; | ^ %Error: t/t_fallback_bad.v:34:20: Can't find definition of 'f' in dotted scope/variable: 'sub1.sub2.f' diff --git a/test_regress/t/t_func_no_paren.py b/test_regress/t/t_func_no_paren.py new file mode 100755 index 000000000..cca4c9e73 --- /dev/null +++ b/test_regress/t/t_func_no_paren.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2025 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() + +test.passes() diff --git a/test_regress/t/t_func_no_paren.v b/test_regress/t/t_func_no_paren.v new file mode 100644 index 000000000..5a65f3dd5 --- /dev/null +++ b/test_regress/t/t_func_no_paren.v @@ -0,0 +1,23 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2025 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +package pkg; + class tb_cpu_seq_item; + virtual function void uvm_report_error(string message); + $display("%s", message); + endfunction + virtual function string get_type_name(); + return "GTN"; + endfunction + virtual function bit do_compare( tb_cpu_seq_item rhs, int comparer); + uvm_report_error($sformatf("this is of type %s, rhs is of type %s", this.get_type_name(), rhs.get_type_name())); + uvm_report_error($sformatf("this is of type %s, rhs is of type %s", this.get_type_name, rhs.get_type_name)); + endfunction + endclass +endpackage + +module t; +endmodule diff --git a/test_regress/t/t_fuzz_always_bad.out b/test_regress/t/t_fuzz_always_bad.out index 33980192a..b864866de 100644 --- a/test_regress/t/t_fuzz_always_bad.out +++ b/test_regress/t/t_fuzz_always_bad.out @@ -1,4 +1,4 @@ -%Error: t/t_fuzz_always_bad.v:10:15: Can't find definition of 'a' in dotted variable: 'c.a' +%Error: t/t_fuzz_always_bad.v:10:15: Can't find definition of 'a' in dotted variable/method: 'c.a' 10 | always @ c.a c:h; | ^ ... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance. diff --git a/test_regress/t/t_inst_missing_dot_bad.out b/test_regress/t/t_inst_missing_dot_bad.out index 6c108c5ed..f71c190a1 100644 --- a/test_regress/t/t_inst_missing_dot_bad.out +++ b/test_regress/t/t_inst_missing_dot_bad.out @@ -2,7 +2,7 @@ 9 | $display("a=", missing.a); | ^~~~~~~ ... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance. -%Error: t/t_inst_missing_dot_bad.v:9:30: Can't find definition of 'a' in dotted variable: 'missing.a' +%Error: t/t_inst_missing_dot_bad.v:9:30: Can't find definition of 'a' in dotted variable/method: 'missing.a' 9 | $display("a=", missing.a); | ^ %Error: Exiting due to