diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 1028ac62e..bda97c8c2 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2765,11 +2765,15 @@ private: m_ds.m_dotSymp = foundp; ok = m_ds.m_dotPos == DP_SCOPE; } else if (const AstNodeFTask* const ftaskp = VN_CAST(foundp->nodep(), NodeFTask)) { - if (!ftaskp->isFunction()) { + + if (!ftaskp->isFunction() || + ftaskp->classMethod() ) { ok = m_ds.m_dotPos == DP_NONE; if (ok) { - // The condition is true for tasks, properties and void functions. + // The condition is true for tasks, + // properties and void functions. // In these cases, the parentheses may be skipped. + // Also SV class methods can be called without parens AstFuncRef* const funcRefp = new AstFuncRef{nodep->fileline(), nodep->name(), nullptr}; nodep->replaceWith(funcRefp); diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index e92ad24f2..621dd013d 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -135,6 +135,9 @@ private: // VISITs void visit(AstNodeFTask* nodep) override { if (!nodep->user1SetOnce()) { // Process only once. + // Mark class methods + if (VN_IS(m_modp, Class)) nodep->classMethod(true); + V3Config::applyFTask(m_modp, nodep); cleanFileline(nodep); VL_RESTORER(m_ftaskp); diff --git a/test_regress/t/t_class_method.v b/test_regress/t/t_class_method.v index b1aefcb5d..0ecf6f832 100644 --- a/test_regress/t/t_class_method.v +++ b/test_regress/t/t_class_method.v @@ -15,6 +15,7 @@ endclass : Cls module t (/*AUTOARG*/); initial begin + int tmp_i; Cls c; if (c != null) $stop; c = new; @@ -24,7 +25,9 @@ module t (/*AUTOARG*/); if (c.get_methoda() != 20) $stop; c.setv_methoda(30); if (c.get_methoda() != 30) $stop; - if (c.get_methoda != 30) $stop; + c.setv_methoda(300); + tmp_i = c.get_methoda; + if (tmp_i != 300) $stop; $write("*-* All Finished *-*\n"); $finish; end