mirror of
https://github.com/verilator/verilator.git
synced 2025-02-02 11:41:55 +00:00
Fix 'this' in extern functions.
This commit is contained in:
parent
ffbae97a3d
commit
ad21f2e850
@ -2024,7 +2024,7 @@ private:
|
|||||||
if (VN_IS(nodep->lhsp(), ParseRef) && nodep->lhsp()->name() == "this") {
|
if (VN_IS(nodep->lhsp(), ParseRef) && nodep->lhsp()->name() == "this") {
|
||||||
VSymEnt* classSymp = m_ds.m_dotSymp;
|
VSymEnt* classSymp = m_ds.m_dotSymp;
|
||||||
do {
|
do {
|
||||||
classSymp = classSymp->fallbackp();
|
classSymp = classSymp->parentp();
|
||||||
} while (classSymp && !VN_IS(classSymp->nodep(), Class));
|
} while (classSymp && !VN_IS(classSymp->nodep(), Class));
|
||||||
m_ds.m_dotSymp = classSymp;
|
m_ds.m_dotSymp = classSymp;
|
||||||
if (!classSymp) {
|
if (!classSymp) {
|
||||||
|
@ -4,22 +4,27 @@
|
|||||||
// any use, without warranty, 2020 Rafal Kapuscik
|
// any use, without warranty, 2020 Rafal Kapuscik
|
||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
//
|
//
|
||||||
class foo;
|
class Cls;
|
||||||
bit [3:0] addr;
|
bit [3:0] addr;
|
||||||
function void set (bit [3:0] addr);
|
function void set(bit [3:0] addr);
|
||||||
begin : body
|
begin : body
|
||||||
this.addr = addr;
|
this.addr = addr;
|
||||||
end : body
|
end : body
|
||||||
endfunction
|
endfunction
|
||||||
|
extern function void setext(bit [3:0] addr);
|
||||||
endclass
|
endclass
|
||||||
|
|
||||||
|
function void Cls::setext(bit [3:0] addr);
|
||||||
|
this.addr = addr;
|
||||||
|
endfunction
|
||||||
|
|
||||||
module t(/*AUTOARG*/
|
module t(/*AUTOARG*/
|
||||||
// Inputs
|
// Inputs
|
||||||
clk
|
clk
|
||||||
);
|
);
|
||||||
input clk;
|
input clk;
|
||||||
foo bar;
|
Cls bar;
|
||||||
foo baz;
|
Cls baz;
|
||||||
initial begin
|
initial begin
|
||||||
bar = new();
|
bar = new();
|
||||||
baz = new();
|
baz = new();
|
||||||
@ -28,6 +33,9 @@ module t(/*AUTOARG*/
|
|||||||
$display(bar.addr);
|
$display(bar.addr);
|
||||||
$display(baz.addr);
|
$display(baz.addr);
|
||||||
`endif
|
`endif
|
||||||
|
if (bar.addr != 4) $stop;
|
||||||
|
bar.setext(2);
|
||||||
|
if (bar.addr != 2) $stop;
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user