Commit 16e4fbd6 authored by Stefan Behnel's avatar Stefan Behnel

more dead code removal for conditionals

parent 491aa659
...@@ -327,8 +327,9 @@ class ExprNode(Node): ...@@ -327,8 +327,9 @@ class ExprNode(Node):
# time we get the result. # time we get the result.
self.analyse_types(env) self.analyse_types(env)
bool = self.coerce_to_boolean(env) bool = self.coerce_to_boolean(env)
temp_bool = bool.coerce_to_temp(env) if not bool.is_simple():
return temp_bool bool = bool.coerce_to_temp(env)
return bool
# --------------- Type Inference ----------------- # --------------- Type Inference -----------------
...@@ -6383,6 +6384,7 @@ class CoerceToTempNode(CoercionNode): ...@@ -6383,6 +6384,7 @@ class CoerceToTempNode(CoercionNode):
def __init__(self, arg, env): def __init__(self, arg, env):
CoercionNode.__init__(self, arg) CoercionNode.__init__(self, arg)
self.type = self.arg.type self.type = self.arg.type
self.constant_result = self.arg.constant_result
self.is_temp = 1 self.is_temp = 1
if self.type.is_pyobject: if self.type.is_pyobject:
self.result_ctype = py_object_type self.result_ctype = py_object_type
...@@ -6395,6 +6397,8 @@ class CoerceToTempNode(CoercionNode): ...@@ -6395,6 +6397,8 @@ class CoerceToTempNode(CoercionNode):
def coerce_to_boolean(self, env): def coerce_to_boolean(self, env):
self.arg = self.arg.coerce_to_boolean(env) self.arg = self.arg.coerce_to_boolean(env)
if self.arg.is_simple():
return self.arg
self.type = self.arg.type self.type = self.arg.type
self.result_ctype = self.type self.result_ctype = self.type
return self return self
......
...@@ -16,11 +16,14 @@ except: pass ...@@ -16,11 +16,14 @@ except: pass
try: break try: break
finally: pass finally: pass
if True: if bool_result():
break break
else: else:
break break
def bool_result():
return True
_ERRORS = u''' _ERRORS = u'''
2:0: break statement not inside loop 2:0: break statement not inside loop
......
...@@ -16,11 +16,13 @@ except: pass ...@@ -16,11 +16,13 @@ except: pass
try: continue try: continue
finally: pass finally: pass
if True: if bool_result():
continue continue
else: else:
continue continue
def bool_result():
return True
_ERRORS = u''' _ERRORS = u'''
2:0: continue statement not inside loop 2:0: continue statement not inside loop
......
def f(): def f():
cdef int* p cdef int* p
if False: if false():
p = [1, 2, 3] p = [1, 2, 3]
def false():
return False
_ERRORS = u""" _ERRORS = u"""
4:10: Literal list must be assigned to pointer at time of declaration 4:10: Literal list must be assigned to pointer at time of declaration
""" """
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