This commit is contained in:
Бондарев Иван 2017-09-29 18:34:48 +02:00
parent 0768b5415e
commit 7b5d548c6d
2 changed files with 14 additions and 1 deletions

View file

@ -5655,7 +5655,10 @@ namespace PascalABCCompiler.NETGenerator
public override void visit(IGotoStatementNode value)
{
Label lab = helper.GetLabel(value.label, il);
il.Emit(OpCodes.Br, lab);
if (safe_block)
il.Emit(OpCodes.Leave, lab);
else
il.Emit(OpCodes.Br, lab);
}
private Stack<Label> if_stack = new Stack<Label>();

10
TestSuite/goto1.pas Normal file
View file

@ -0,0 +1,10 @@
label c1;
begin
var s := 0;
foreach var i in range(0, 2) do
begin
goto c1;
s := 2;
end;
c1: assert(s=0);
end.