Commit efc33c7c authored by Mark Florisson's avatar Mark Florisson

Disallow taking address of memoryview slices

parent 59c083a1
......@@ -244,7 +244,7 @@ class ExprNode(Node):
return 0
def is_addressable(self):
return self.is_lvalue()
return self.is_lvalue() and not self.type.is_memoryviewslice
def is_ephemeral(self):
# An ephemeral node is one whose result is in
......@@ -1638,7 +1638,7 @@ class NameNode(AtomicExprNode):
not self.entry.is_readonly
def is_addressable(self):
return self.entry.is_variable
return self.entry.is_variable and not self.type.is_memoryviewslice
def is_ephemeral(self):
# Name nodes are never ephemeral, even if the
......@@ -7069,6 +7069,9 @@ class AmpersandNode(ExprNode):
self.operand.analyse_types(env)
argtype = self.operand.type
if not (argtype.is_cfunction or self.operand.is_addressable()):
if argtype.is_memoryviewslice:
self.error("Cannot take address of memoryview slice")
else:
self.error("Taking address of non-lvalue")
return
if argtype.is_pyobject:
......
......@@ -60,6 +60,9 @@ four_D[None, None, None, None, None]
cdef int[:, :, :, :, :, :, :, :] eight_D = object()
cdef double[:] m
print <long> &m
# These are VALID
cdef int[::view.indirect_contiguous, ::view.contiguous] a9
four_D[None, None, None]
......@@ -89,4 +92,5 @@ _ERRORS = u'''
58:6: More dimensions than the maximum number of buffer dimensions were used.
59:6: More dimensions than the maximum number of buffer dimensions were used.
61:9: More dimensions than the maximum number of buffer dimensions were used.
64:13: Cannot take address of memoryview slice
'''
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