cython
changeset 1380:04e83ffd8ea2
conservative fix for empty switch statements
| author | Stefan Behnel <scoder@users.berlios.de> |
|---|---|
| date | Fri Nov 07 06:55:37 2008 +0100 (4 years ago) |
| parents | 78891b99533b |
| children | 43d4e2b1913413d4c8b44618 |
| files | Cython/Compiler/Nodes.py tests/run/switch.pyx |
line diff
1.1 --- a/Cython/Compiler/Nodes.py Tue Nov 18 20:50:58 2008 -0800
1.2 +++ b/Cython/Compiler/Nodes.py Fri Nov 07 06:55:37 2008 +0100
1.3 @@ -3469,6 +3469,7 @@
1.4 if self.else_clause is not None:
1.5 code.putln("default:")
1.6 self.else_clause.generate_execution_code(code)
1.7 + code.putln("break;")
1.8 code.putln("}")
1.9
1.10 def annotate(self, code):
2.1 --- a/tests/run/switch.pyx Tue Nov 18 20:50:58 2008 -0800
2.2 +++ b/tests/run/switch.pyx Fri Nov 07 06:55:37 2008 +0100
2.3 @@ -89,6 +89,9 @@
2.4 1
2.5 >>> switch_off(2)
2.6 0
2.7 +
2.8 +>>> switch_pass(1)
2.9 +1
2.10 """
2.11
2.12 def switch_simple_py(x):
2.13 @@ -173,3 +176,12 @@
2.14 else:
2.15 return 0
2.16 return -1
2.17 +
2.18 +def switch_pass(int x):
2.19 + if x == 1:
2.20 + pass
2.21 + elif x == 2:
2.22 + pass
2.23 + else:
2.24 + pass
2.25 + return x
