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
50cba685
Commit
50cba685
authored
Nov 10, 2011
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Array variables have an address despite not being lvalues.
parent
7b8f9874
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+7
-1
tests/run/array_address.pyx
tests/run/array_address.pyx
+14
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
50cba685
...
...
@@ -237,6 +237,9 @@ class ExprNode(Node):
def
is_lvalue
(
self
):
return
0
def
is_addressable
(
self
):
return
self
.
is_lvalue
()
def
is_ephemeral
(
self
):
# An ephemeral node is one whose result is in
# a Python temporary and we suspect there are no
...
...
@@ -1619,6 +1622,9 @@ class NameNode(AtomicExprNode):
not
self
.
entry
.
type
.
is_array
and
\
not
self
.
entry
.
is_readonly
def
is_addressable
(
self
):
return
self
.
entry
.
is_variable
def
is_ephemeral
(
self
):
# Name nodes are never ephemeral, even if the
# result is in a temporary.
...
...
@@ -6576,7 +6582,7 @@ class AmpersandNode(ExprNode):
def
analyse_types
(
self
,
env
):
self
.
operand
.
analyse_types
(
env
)
argtype
=
self
.
operand
.
type
if
not
(
argtype
.
is_cfunction
or
self
.
operand
.
is_
lvalu
e
()):
if
not
(
argtype
.
is_cfunction
or
self
.
operand
.
is_
addressabl
e
()):
self
.
error
(
"Taking address of non-lvalue"
)
return
if
argtype
.
is_pyobject
:
...
...
tests/run/array_address.pyx
0 → 100644
View file @
50cba685
ctypedef
int
five_ints
[
5
]
def
test_array_address
(
int
ix
,
int
x
):
"""
>>> test_array_address(0, 100)
100
>>> test_array_address(2, 200)
200
"""
cdef
five_ints
a
a
[:]
=
[
1
,
2
,
3
,
4
,
5
]
cdef
five_ints
*
a_ptr
=
&
a
a_ptr
[
0
][
ix
]
=
x
return
a
[
ix
]
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