From f277fa1f4bf03b7f2da0dd65abc6e0f600e45b92 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 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 -- 2.26.2