diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs b/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs index 06dabbfcc..ce3d0f43d 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs @@ -235,7 +235,6 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow /// This method must not write to the Visited flags on the CFG. ControlFlowNode FindExitPoint(ControlFlowNode loopHead, IReadOnlyList naturalLoop, bool treatBackEdgesAsExits) { - treatBackEdgesAsExits = false; bool hasReachableExit = context.ControlFlowGraph.HasReachableExit(loopHead); if (!hasReachableExit && treatBackEdgesAsExits) { // If we're analyzing the switch, there's no reachable exit, but the loopHead (=switchHead) block @@ -314,7 +313,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow return true; } foreach (var succ in node.Successors) { - if (loopHead.Dominates(succ) && !exitPoint.Dominates(succ)) + if (loopHead != succ && loopHead.Dominates(succ) && !exitPoint.Dominates(succ)) return false; } foreach (var child in node.DominatorTreeChildren) {