Commit 673e8007 authored by Stefan Behnel's avatar Stefan Behnel

mark infinite while loops as terminators when looking for unreachable code

parent 07e66a55
......@@ -2162,6 +2162,12 @@ class RemoveUnreachableCode(CythonTransform):
node.is_terminator = True
return node
def visit_WhileStatNode(self, node):
self.visitchildren(node)
if not node.condition:
node.is_terminator = True
return node
def visit_TryExceptStatNode(self, node):
self.visitchildren(node)
if node.body.is_terminator and node.else_clause:
......
......@@ -31,6 +31,10 @@ def try_except():
else:
print 'unreachable'
def infinite_loops():
while True:
pass
print 'Never be here'
_ERRORS = """
6:4: Unreachable code
......@@ -38,4 +42,5 @@ _ERRORS = """
15:8: Unreachable code
24:4: Unreachable code
32:8: Unreachable code
37:4: Unreachable code
"""
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment