Commit 9e2fc1bc authored by Stefan Behnel's avatar Stefan Behnel

make the RHS of assignments safe if the LHS target is a subset of a RHS attribute access

--HG--
extra : transplant_source : %D5%C52%5C7%CD%85%8F%3D7%9C%27%C6%8AGb%DBX%AEe
parent ee1686c0
...@@ -4430,8 +4430,11 @@ class SingleAssignmentNode(AssignmentNode): ...@@ -4430,8 +4430,11 @@ class SingleAssignmentNode(AssignmentNode):
dtype = self.lhs.type dtype = self.lhs.type
self.rhs = self.rhs.coerce_to(dtype, env) self.rhs = self.rhs.coerce_to(dtype, env)
if use_temp: if use_temp or self.rhs.is_attribute:
# cdef attribute access traverses pointers
self.rhs = self.rhs.coerce_to_temp(env) self.rhs = self.rhs.coerce_to_temp(env)
else:
self.rhs = self.rhs.coerce_to_simple(env)
def generate_rhs_evaluation_code(self, code): def generate_rhs_evaluation_code(self, code):
self.rhs.generate_evaluation_code(code) self.rhs.generate_evaluation_code(code)
...@@ -4470,11 +4473,11 @@ class CascadedAssignmentNode(AssignmentNode): ...@@ -4470,11 +4473,11 @@ class CascadedAssignmentNode(AssignmentNode):
from ExprNodes import CloneNode, ProxyNode from ExprNodes import CloneNode, ProxyNode
self.rhs.analyse_types(env) self.rhs.analyse_types(env)
if not self.rhs.is_simple(): if use_temp or self.rhs.is_attribute:
if use_temp: # (cdef) attribute access traverses pointers
self.rhs = self.rhs.coerce_to_temp(env) self.rhs = self.rhs.coerce_to_temp(env)
else: else:
self.rhs = self.rhs.coerce_to_simple(env) self.rhs = self.rhs.coerce_to_simple(env)
self.rhs = ProxyNode(self.rhs) self.rhs = ProxyNode(self.rhs)
self.coerced_rhs_list = [] self.coerced_rhs_list = []
......
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