Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
efc33c7c
Commit
efc33c7c
authored
May 16, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow taking address of memoryview slices
parent
59c083a1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-3
tests/errors/memview_declarations.pyx
tests/errors/memview_declarations.pyx
+4
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
efc33c7c
...
...
@@ -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
:
...
...
tests/errors/memview_declarations.pyx
View file @
efc33c7c
...
...
@@ -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
'''
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment