This commit is contained in:
Бондарев Иван 2018-04-08 17:44:06 +02:00
parent 76ad00bf41
commit 24cbba475a
2 changed files with 56 additions and 0 deletions

View file

@ -10399,7 +10399,9 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Stloc, lb); il.Emit(OpCodes.Stloc, lb);
il.Emit(OpCodes.Call, _monitor_enter); il.Emit(OpCodes.Call, _monitor_enter);
il.BeginExceptionBlock(); il.BeginExceptionBlock();
bool safe_block = EnterSafeBlock();
ConvertStatement(value.Body); ConvertStatement(value.Body);
LeaveSafeBlock(safe_block);
il.BeginFinallyBlock(); il.BeginFinallyBlock();
il.Emit(OpCodes.Ldloc, lb); il.Emit(OpCodes.Ldloc, lb);
il.Emit(OpCodes.Call, _monitor_exit); il.Emit(OpCodes.Call, _monitor_exit);

54
TestSuite/lock1.pas Normal file
View file

@ -0,0 +1,54 @@
type t1 = class end;//любой ссылочный тип
var i: integer;
procedure p1;
begin
lock new t1 do
begin
i := 1;
exit;
end;
end;
procedure p2;
begin
loop 1 do
lock new t1 do
begin
i := 2;
continue;
end;
end;
procedure p3;
begin
loop 1 do
lock new t1 do
begin
i := 3;
break;
end;
end;
procedure p4;
label l1;
begin
lock new t1 do
begin
i := 4;
goto l1;
end;
l1:
end;
begin
p1;
assert(i = 1);
p2;
assert(i = 2);
p3;
assert(i = 3);
p4;
assert(i = 4);
end.