Skip to content

Commit

Permalink
Fix #1047: Unsupported method
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Jan 27, 2018
1 parent 5f68f80 commit ebf213d
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 1 deletion.
Expand Up @@ -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" />
Expand All @@ -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" />
Expand Down
6 changes: 6 additions & 0 deletions ICSharpCode.Decompiler.Tests/ILPrettyTestRunner.cs
Expand Up @@ -54,6 +54,12 @@ public void Issue982()
Run();
}

[Test]
public void Issue1047()
{
Run();
}

[Test]
public void FSharpUsing_Debug()
{
Expand Down
24 changes: 24 additions & 0 deletions ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1047.cs
@@ -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 changes: 72 additions & 0 deletions ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue1047.il
@@ -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 changes: 1 addition & 1 deletion ICSharpCode.Decompiler/CSharp/StatementBuilder.cs
Expand Up @@ -723,7 +723,7 @@ protected internal override Statement VisitBlock(Block block)

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;
Expand Down

0 comments on commit ebf213d

Please sign in to comment.