From: Stefan Behnel Date: Fri, 7 Nov 2008 05:55:37 +0000 (+0100) Subject: conservative fix for empty switch statements X-Git-Tag: 0.10.2~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f277fa1f4bf03b7f2da0dd65abc6e0f600e45b92;p=cython.git conservative fix for empty switch statements --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 119e5d4f..bd583d80 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -3469,6 +3469,7 @@ class SwitchStatNode(StatNode): if self.else_clause is not None: code.putln("default:") self.else_clause.generate_execution_code(code) + code.putln("break;") code.putln("}") def annotate(self, code): diff --git a/tests/run/switch.pyx b/tests/run/switch.pyx index 80f16f7d..36ab9287 100644 --- a/tests/run/switch.pyx +++ b/tests/run/switch.pyx @@ -89,6 +89,9 @@ __doc__ = u""" 1 >>> switch_off(2) 0 + +>>> switch_pass(1) +1 """ def switch_simple_py(x): @@ -173,3 +176,12 @@ def switch_off(int x): else: return 0 return -1 + +def switch_pass(int x): + if x == 1: + pass + elif x == 2: + pass + else: + pass + return x