Commit d2c1b777 authored by Stefan Behnel's avatar Stefan Behnel

fix ticket 154: C compilation error for unused local buffer variables

parent 3f684dfe
...@@ -12,6 +12,9 @@ Bugs fixed ...@@ -12,6 +12,9 @@ Bugs fixed
* Invalid C code for some builtin methods. This fixes ticket 856. * Invalid C code for some builtin methods. This fixes ticket 856.
* Invalid C code for unused local buffer variables.
This fixes ticket 154.
* Test failures on 32bit systems. This fixes ticket 857. * Test failures on 32bit systems. This fixes ticket 857.
* Code that uses "from xyz import *" and global C struct/union/array * Code that uses "from xyz import *" and global C struct/union/array
......
...@@ -1955,6 +1955,7 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1955,6 +1955,7 @@ class FuncDefNode(StatNode, BlockNode):
code.putln("{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;") code.putln("{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;")
code.putln("__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);") code.putln("__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);")
for entry in lenv.buffer_entries: for entry in lenv.buffer_entries:
if entry.used:
Buffer.put_release_buffer_code(code, entry) Buffer.put_release_buffer_code(code, entry)
#code.putln("%s = 0;" % entry.cname) #code.putln("%s = 0;" % entry.cname)
code.putln("__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}") code.putln("__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}")
......
...@@ -45,6 +45,7 @@ def nousage(): ...@@ -45,6 +45,7 @@ def nousage():
cdef object[int, ndim=2] buf cdef object[int, ndim=2] buf
@testcase
def disabled_usage(obj): def disabled_usage(obj):
""" """
The challenge here is just compilation. The challenge here is just compilation.
...@@ -57,6 +58,19 @@ def disabled_usage(obj): ...@@ -57,6 +58,19 @@ def disabled_usage(obj):
return obj return obj
@testcase
def nousage_cleanup(x):
"""
>>> nousage_cleanup(False)
>>> nousage_cleanup(True)
Traceback (most recent call last):
RuntimeError
"""
cdef object[int, ndim=2] buf
if x:
raise RuntimeError()
@testcase @testcase
def acquire_release(o1, o2): def acquire_release(o1, o2):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment