From 63fa4ef3eaff9df93a82e3167dd20540370fed26 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 7 Nov 2008 06:55:37 +0100 Subject: [PATCH] conservative fix for empty switch statements --- Cython/Compiler/Nodes.py | 1 + tests/run/switch.pyx | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index e82ae755..f127e56d 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 -- 2.26.2