From 540394db13aab0ab9907ec44dcdcd81cf7ca6091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Sun, 26 Jul 2015 17:18:27 +0200 Subject: [PATCH] bug fix for .NET 4.6: exit in except block caused runtime error --- NETGenerator/NETGenerator.cs | 5 ++++- TestSuite/CompilationSamples/PABCSystem.pas | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index ec74cc427..3a9527190 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -10290,7 +10290,10 @@ namespace PascalABCCompiler.NETGenerator { if (!ExitProcedureCall) ExitLabel = il.DefineLabel(); - il.Emit(OpCodes.Br, ExitLabel); + if (!safe_block) + il.Emit(OpCodes.Br, ExitLabel); + else + il.Emit(OpCodes.Leave, ExitLabel); ExitProcedureCall = true; } diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index b9a18c3c5..40091a97a 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -1964,7 +1964,7 @@ begin on e: System.Exception do begin Result := nil; - Exit; + //Exit; end; end; end;