Browse Source

Fix #1047: Unsupported method

pull/1051/head
Siegfried Pammer 8 years ago
parent
commit
ebf213d85e
  1. 2
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 6
      ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
  3. 24
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1047.cs
  4. 72
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1047.il
  5. 2
      ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

2
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -62,6 +62,7 @@ @@ -62,6 +62,7 @@
<Compile Include="TestCases\Correctness\LINQRaytracer.cs" />
<Compile Include="TestCases\Correctness\MiniJSON.cs" />
<Compile Include="TestCases\Correctness\FloatingPointArithmetic.cs" />
<None Include="TestCases\ILPretty\Issue1047.cs" />
<Compile Include="TestCases\ILPretty\Issue982.cs" />
<Compile Include="TestCases\Pretty\AsyncMain.cs" />
<Compile Include="TestCases\Pretty\CS72_PrivateProtected.cs" />
@ -70,6 +71,7 @@ @@ -70,6 +71,7 @@
<Compile Include="TestCases\Pretty\VariableNaming.cs" />
<Compile Include="TestCases\Pretty\VariableNamingWithoutSymbols.cs" />
<Compile Include="Util\SequencePointTests.cs" />
<None Include="TestCases\ILPretty\Issue1047.il" />
<None Include="TestCases\ILPretty\Issue959.cs" />
<None Include="TestCases\ILPretty\FSharpLoops_Debug.cs" />
<None Include="TestCases\ILPretty\FSharpLoops_Release.cs" />

6
ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs

@ -54,6 +54,12 @@ namespace ICSharpCode.Decompiler.Tests @@ -54,6 +54,12 @@ namespace ICSharpCode.Decompiler.Tests
Run();
}
[Test]
public void Issue1047()
{
Run();
}
[Test]
public void FSharpUsing_Debug()
{

24
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1047.cs

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
namespace ICSharpCode.Decompiler.Tests.TestCases.ILPretty
{
public class Issue1047
{
private void ProblemMethod()
{
IL_0000:
do {
if (/*Error near IL_0001: Stack underflow*/ >= /*Error near IL_0001: Stack underflow*/) {
if ((int)/*Error near IL_0007: Stack underflow*/ == 0) {
return;
}
return;
}
} while ((int)/*Error near IL_0014: Stack underflow*/ == 0);
if (/*Error near IL_0020: Stack underflow*/ > /*Error near IL_0020: Stack underflow*/&& (int)/*Error near IL_0026: Stack underflow*/ != 0 && (int)/*Error near IL_002c: Stack underflow*/ == 0) {
return;
}
return;
IL_0037:
goto IL_0000;
}
}
}

72
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1047.il

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly extern System
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly extern System.Core
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly ConsoleApp11
{
.ver 1:0:0:0
}
.module ConsoleApp11.exe
// MVID: {B973FCD6-A9C4-48A9-8291-26DDC248E208}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00020003 // ILONLY 32BITPREFERRED
// Image base: 0x000001C4B6C90000
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.ILPretty.Issue1047
{
.method private hidebysig instance void ProblemMethod() cil managed
{
.maxstack 4
// loop start
IL_0000: nop
blt IL_0047
nop
brfalse IL_0037
nop
IL_0037: nop
br L_exit
IL_0047: nop
brtrue IL_0083
nop
br IL_0000
IL_0083: nop
ble.un IL_00fa
nop
brfalse IL_00db
nop
brfalse IL_00fa
IL_00db: nop
IL_00fa: br L_exit
br IL_0000
// end loop
L_exit: ret
}
}

2
ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

@ -723,7 +723,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -723,7 +723,7 @@ namespace ICSharpCode.Decompiler.CSharp
protected internal override Statement VisitBlockContainer(BlockContainer container)
{
if (container.EntryPoint.IncomingEdgeCount > 1) {
if (container.Kind != ContainerKind.Normal && container.EntryPoint.IncomingEdgeCount > 1) {
var oldContinueTarget = continueTarget;
var oldContinueCount = continueCount;
var oldBreakTarget = breakTarget;

Loading…
Cancel
Save