Commit 47563ef6 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Fixed bug related to non-usage of local buffer variable

parent 72accb34
...@@ -63,8 +63,8 @@ class IntroduceBufferAuxiliaryVars(CythonTransform): ...@@ -63,8 +63,8 @@ class IntroduceBufferAuxiliaryVars(CythonTransform):
cname = scope.mangle(Naming.bufstruct_prefix, name) cname = scope.mangle(Naming.bufstruct_prefix, name)
bufinfo = scope.declare_var(name="$%s" % cname, cname=cname, bufinfo = scope.declare_var(name="$%s" % cname, cname=cname,
type=PyrexTypes.c_py_buffer_type, pos=node.pos) type=PyrexTypes.c_py_buffer_type, pos=node.pos)
if entry.is_arg:
bufinfo.used = True bufinfo.used = True # otherwise, NameNode will mark whether it is used
def var(prefix, idx, initval): def var(prefix, idx, initval):
cname = scope.mangle(prefix, "%d_%s" % (idx, name)) cname = scope.mangle(prefix, "%d_%s" % (idx, name))
......
...@@ -935,6 +935,7 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -935,6 +935,7 @@ class FuncDefNode(StatNode, BlockNode):
# goto statement in error cleanup above # goto statement in error cleanup above
code.put_label(code.return_label) code.put_label(code.return_label)
for entry in lenv.buffer_entries: for entry in lenv.buffer_entries:
if entry.used:
code.putln("%s;" % Buffer.get_release_buffer_code(entry)) code.putln("%s;" % Buffer.get_release_buffer_code(entry))
# ----- Return cleanup for both error and no-error return # ----- Return cleanup for both error and no-error return
code.put_label(code.return_from_error_cleanup_label) code.put_label(code.return_from_error_cleanup_label)
......
...@@ -34,6 +34,15 @@ def testcas(a): ...@@ -34,6 +34,15 @@ def testcas(a):
# Buffer acquire and release tests # Buffer acquire and release tests
# #
@testcase
def nousage():
"""
>>> True
True
"""
cdef object[int, 2] buf
# this used not to compile
@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