[pypy-svn] r25575 - pypy/dist/pypy/translator/c

mwh at codespeak.net mwh at codespeak.net
Sat Apr 8 19:39:10 CEST 2006


Author: mwh
Date: Sat Apr  8 19:39:03 2006
New Revision: 25575

Modified:
   pypy/dist/pypy/translator/c/funcgen.py
Log:
do a run time, rather than compile time, assert in the case of a switch not
having a default case.


Modified: pypy/dist/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/dist/pypy/translator/c/funcgen.py	(original)
+++ pypy/dist/pypy/translator/c/funcgen.py	Sat Apr  8 19:39:03 2006
@@ -266,12 +266,13 @@
                             yield '\t' + op
                         yield 'break;'
                         
-                    # ? Emit default case
-                    if defaultlink is None:
-                        raise TypeError('switches must have a default case.')
+                    # Emit default case
                     yield 'default:'
-                    for op in self.gen_link(defaultlink):
-                        yield '\t' + op
+                    if defaultlink is None:
+                        yield '\tassert(!"bad switch!!");'
+                    else:
+                        for op in self.gen_link(defaultlink):
+                            yield '\t' + op
 
                     yield '}'
                 else:



More information about the Pypy-commit mailing list