mirror of https://github.com/zachjs/sv2v.git
fix break/continue causing return after loop
This commit is contained in:
parent
bbb469463b
commit
f0a5a47371
|
|
@ -261,13 +261,19 @@ convertLoop loop comp stmt = do
|
|||
(BinOp Ne (Ident jumpState) jsReturn)
|
||||
(asgn jumpState (Ident jsStackIdent))
|
||||
Null
|
||||
let jsCheckReturn = If NoCheck
|
||||
(BinOp Ne (Ident jumpState) jsReturn)
|
||||
(asgn jumpState jsNone)
|
||||
Null
|
||||
|
||||
return $
|
||||
if not afterHasJump then
|
||||
loop comp stmt'
|
||||
else if origLoopDepth == 0 then
|
||||
Block Seq "" []
|
||||
[ loop comp' body ]
|
||||
[ loop comp' body
|
||||
, jsCheckReturn
|
||||
]
|
||||
else
|
||||
Block Seq ""
|
||||
[ jsStackDecl ]
|
||||
|
|
|
|||
|
|
@ -114,4 +114,26 @@ module top;
|
|||
end
|
||||
initial #5 $finish;
|
||||
|
||||
initial begin
|
||||
for (int unsigned i = 0; i < 5; ++i) begin
|
||||
$display("Loop D-1:", i);
|
||||
if (i == 3) begin
|
||||
$display("Loop D-2:", i);
|
||||
break;
|
||||
$display("UNREACHABLE ", `__LINE__);
|
||||
end
|
||||
$display("Loop D-3:", i);
|
||||
end
|
||||
for (int unsigned i = 0; i < 5; i++) begin
|
||||
$display("Loop E-1:", i);
|
||||
if (i == 2) begin
|
||||
$display("Loop E-2:", i);
|
||||
break;
|
||||
$display("UNREACHABLE ", `__LINE__);
|
||||
end
|
||||
$display("Loop E-3:", i);
|
||||
end
|
||||
$display("Block F-1");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
|
|||
|
|
@ -89,4 +89,27 @@ module top;
|
|||
end
|
||||
initial #5 $finish;
|
||||
|
||||
initial begin : loops_de
|
||||
reg unsigned [31:0] i;
|
||||
for (i = 0; i < 5; ++i) begin
|
||||
$display("Loop D-1:", i);
|
||||
if (i == 3) begin
|
||||
$display("Loop D-2:", i);
|
||||
i = 5;
|
||||
end
|
||||
else
|
||||
$display("Loop D-3:", i);
|
||||
end
|
||||
for (i = 0; i < 5; i++) begin
|
||||
$display("Loop E-1:", i);
|
||||
if (i == 2) begin
|
||||
$display("Loop E-2:", i);
|
||||
i = 5;
|
||||
end
|
||||
else
|
||||
$display("Loop E-3:", i);
|
||||
end
|
||||
$display("Block F-1");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
|
|||
Loading…
Reference in New Issue