Fix static methods with prototypes (#4220)

This commit is contained in:
Ryszard Rozak 2023-06-01 03:18:32 +02:00 committed by GitHub
parent 205cae963b
commit 15f8ebc562
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -3250,7 +3250,16 @@ private:
UINFO(5, " " << nodep << endl);
checkNoDot(nodep);
if (nodep->isExternDef()) {
if (!m_curSymp->findIdFallback("extern " + nodep->name())) {
if (const VSymEnt* const foundp
= m_curSymp->findIdFallback("extern " + nodep->name())) {
const AstNodeFTask* const funcProtop = VN_AS(foundp->nodep(), NodeFTask);
// Copy specifiers.
// External definition cannot have any specifiers, so no value will be overwritten.
nodep->isHideLocal(funcProtop->isHideLocal());
nodep->isHideProtected(funcProtop->isHideProtected());
nodep->isVirtual(funcProtop->isVirtual());
nodep->lifetime(funcProtop->lifetime());
} else {
nodep->v3error("extern not found that declares " + nodep->prettyNameQ());
}
}

View File

@ -9,6 +9,7 @@ class Cls;
extern function int ext_f_np;
extern function int ext_f_p();
extern function int ext_f_i(int in);
extern static function int get_1();
extern task ext_t_np;
extern task ext_t_p();
extern task ext_t_i(int in);
@ -26,6 +27,10 @@ function int Cls::ext_f_i(int in);
return in+1;
endfunction
function int Cls::get_1();
return 1;
endfunction
task Cls::ext_t_np();
$write("*-* All Finished *-*\n");
endtask
@ -46,5 +51,6 @@ module t (/*AUTOARG*/);
if (c.ext_f_np() != 1) $stop;
if (c.ext_f_p() != 2) $stop;
if (c.ext_f_i(10) != 11) $stop;
if (Cls::get_1() != 1) $stop;
end
endmodule