Fix `randsequence return` inside function
This commit is contained in:
parent
60fe2c873c
commit
9a1dba357e
|
|
@ -356,14 +356,14 @@ class LinkJumpVisitor final : public VNVisitor {
|
|||
void visit(AstReturn* nodep) override {
|
||||
iterateChildren(nodep);
|
||||
const AstFunc* const funcp = VN_CAST(m_ftaskp, Func);
|
||||
if (m_inFork) {
|
||||
nodep->v3error("Return isn't legal under fork (IEEE 1800-2023 9.2.3)");
|
||||
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
|
||||
return;
|
||||
} else if (!m_ftaskp && m_randsequencep) {
|
||||
if (m_randsequencep) {
|
||||
nodep->replaceWith(new AstRSReturn{nodep->fileline()});
|
||||
VL_DO_DANGLING(pushDeletep(nodep), nodep);
|
||||
return;
|
||||
} else if (m_inFork) {
|
||||
nodep->v3error("Return isn't legal under fork (IEEE 1800-2023 9.2.3)");
|
||||
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
|
||||
return;
|
||||
} else if (!m_ftaskp) {
|
||||
nodep->v3error("Return isn't underneath a task or function");
|
||||
} else if (funcp && !nodep->lhsp() && !funcp->isConstructor()) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,19 @@
|
|||
|
||||
module t;
|
||||
|
||||
function int abort_break();
|
||||
int x;
|
||||
static int return_on = 1;
|
||||
randsequence( main )
|
||||
main : first second third;
|
||||
first : { x = x + 20; };
|
||||
second : { if (return_on == 1) return; x = x + 10; };
|
||||
third : { x = x + 5;};
|
||||
endsequence
|
||||
return x;
|
||||
endfunction
|
||||
|
||||
|
||||
initial begin
|
||||
int x;
|
||||
bit flag = 1;
|
||||
|
|
@ -133,7 +146,7 @@ module t;
|
|||
main : first second third;
|
||||
first : { x = x + 20; };
|
||||
second : { if (return_on == 1) return; x = x + 10; };
|
||||
third : { x = x + 5;};
|
||||
third : { x = x + 5; };
|
||||
endsequence
|
||||
`checkd(x, 25);
|
||||
|
||||
|
|
@ -143,7 +156,7 @@ module t;
|
|||
main : first second third;
|
||||
first : { x = x + 20; };
|
||||
second : { if (return_on == 1) return; x = x + 10; };
|
||||
third : { x = x + 5;};
|
||||
third : { x = x + 5; };
|
||||
endsequence
|
||||
`checkd(x, 35);
|
||||
|
||||
|
|
@ -160,6 +173,9 @@ module t;
|
|||
`checkd(x, 17);
|
||||
`endif
|
||||
|
||||
x = abort_break();
|
||||
`checkd(x, 25);
|
||||
|
||||
$finish;
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue