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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
b352c600
Commit
b352c600
authored
Sep 24, 2013
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #246 from dalleyg/dalleyg-lvalue1
Fixed IndexNode.is_lvalue
parents
29ff5abe
bcba9251
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
4 deletions
+45
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+15
-4
tests/run/lvalue_refs.pyx
tests/run/lvalue_refs.pyx
+30
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
b352c600
...
...
@@ -3204,10 +3204,21 @@ class IndexNode(ExprNode):
return
self
.
base
.
check_const_addr
()
and
self
.
index
.
check_const
()
def
is_lvalue
(
self
):
base_type
=
self
.
base
.
type
if
self
.
type
.
is_ptr
or
self
.
type
.
is_array
:
return
not
base_type
.
base_type
.
is_array
else
:
# NOTE: references currently have both is_reference and is_ptr
# set. Since pointers and references have different lvalue
# rules, we must be careful to separate the two.
if
self
.
type
.
is_reference
:
if
self
.
type
.
ref_base_type
.
is_array
:
# fixed-sized arrays aren't l-values
return
False
elif
self
.
type
.
is_ptr
:
# non-const pointers can always be reassigned
return
True
elif
self
.
type
.
is_array
:
# fixed-sized arrays aren't l-values
return
False
# Just about everything else returned by the index operator
# can be an lvalue.
return
True
def
calculate_result_code
(
self
):
...
...
tests/run/lvalue_refs.pyx
0 → 100644
View file @
b352c600
# tag: cpp
from
libcpp.vector
cimport
vector
__doc__
=
u"""
>>> test_lvalue_ref_assignment()
"""
ctypedef
double
*
dp
ctypedef
double
**
dpp
cdef
void
foo
(
vector
[
dpp
]
&
bar
,
vector
[
vector
[
dp
]]
&
baz
)
nogil
:
bar
[
0
]
=
&
baz
[
0
][
0
]
def
test_lvalue_ref_assignment
():
cdef
vector
[
dpp
]
bar
cdef
vector
[
vector
[
dp
]]
baz
cdef
vector
[
double
]
data
cdef
dp
bongle
=
&
data
[
0
]
bar
.
resize
(
1
)
bar
[
0
]
=
NULL
baz
.
resize
(
1
)
baz
[
0
].
resize
(
1
)
baz
[
0
][
0
]
=
bongle
foo
(
bar
,
baz
)
assert
bar
[
0
]
==
&
baz
[
0
][
0
]
assert
bar
[
0
][
0
]
==
bongle
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