Commit f0a5a473 by Zachary Snow

fix break/continue causing return after loop

parent bbb46946
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment