Commit 55b5ae9e authored by Robert Bradshaw's avatar Robert Bradshaw

Generate subexpression code for deletion of C++ classes.

parent e1e33240
...@@ -5452,8 +5452,9 @@ class DelStatNode(StatNode): ...@@ -5452,8 +5452,9 @@ class DelStatNode(StatNode):
arg.generate_deletion_code( arg.generate_deletion_code(
code, ignore_nonexisting=self.ignore_nonexisting) code, ignore_nonexisting=self.ignore_nonexisting)
elif arg.type.is_ptr and arg.type.base_type.is_cpp_class: elif arg.type.is_ptr and arg.type.base_type.is_cpp_class:
arg.generate_result_code(code) arg.generate_evaluation_code(code)
code.putln("delete %s;" % arg.result()) code.putln("delete %s;" % arg.result())
arg.generate_disposal_code(code)
# else error reported earlier # else error reported earlier
def annotate(self, code): def annotate(self, code):
......
...@@ -179,3 +179,18 @@ def test_template_class_member(): ...@@ -179,3 +179,18 @@ def test_template_class_member():
del o del o
assert destructor_count - start_destructor_count == 2, \ assert destructor_count - start_destructor_count == 2, \
destructor_count - start_destructor_count destructor_count - start_destructor_count
ctypedef vector[int]* vector_int_ptr
cdef vector[vector_int_ptr] create_to_delete() except *:
cdef vector[vector_int_ptr] v
v.push_back(new vector[int]())
return v
cdef int f(int x):
return x
def test_nested_del():
cdef vector[vector_int_ptr] v
v.push_back(new vector[int]())
del v[0]
del create_to_delete()[f(f(0))]
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