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
Boxiang Sun
cython
Commits
d3c79c9b
Commit
d3c79c9b
authored
Oct 14, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable array literals outside of pointer declaration
parent
9b19cce7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+7
-3
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+1
-2
tests/errors/literal_lists.pyx
tests/errors/literal_lists.pyx
+8
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
d3c79c9b
...
...
@@ -935,7 +935,7 @@ class NameNode(AtomicExprNode):
is_name
=
True
is_cython_module
=
False
cython_attribute
=
None
skip_assignment_decref
=
False
lhs_of_first_assignment
=
False
entry
=
None
def
create_analysed_rvalue
(
pos
,
env
,
entry
):
...
...
@@ -1156,6 +1156,10 @@ class NameNode(AtomicExprNode):
entry
=
self
.
entry
if
entry
is
None
:
return
# There was an error earlier
if
(
self
.
entry
.
type
.
is_ptr
and
isinstance
(
rhs
,
ListNode
)
and
not
self
.
lhs_of_first_assignment
):
error
(
self
.
pos
,
"Literal list must be assigned to pointer at time of declaration"
)
# is_pyglobal seems to be True for module level-globals only.
# We use this to access class->tp_dict if necessary.
...
...
@@ -1200,7 +1204,7 @@ class NameNode(AtomicExprNode):
#print "...from", rhs ###
#print "...LHS type", self.type, "ctype", self.ctype() ###
#print "...RHS type", rhs.type, "ctype", rhs.ctype() ###
if
not
self
.
skip_assignment_decref
:
if
not
self
.
lhs_of_first_assignment
:
if
entry
.
is_local
and
not
Options
.
init_local_none
:
initalized
=
entry
.
scope
.
control_flow
.
get_state
((
entry
.
name
,
'initalized'
),
self
.
pos
)
if
initalized
is
True
:
...
...
@@ -1223,7 +1227,7 @@ class NameNode(AtomicExprNode):
import
Buffer
Buffer
.
put_assign_to_buffer
(
self
.
result
(),
rhstmp
,
buffer_aux
,
self
.
entry
.
type
,
is_initialized
=
not
self
.
skip_assignment_decref
,
is_initialized
=
not
self
.
lhs_of_first_assignment
,
pos
=
self
.
pos
,
code
=
code
)
code
.
putln
(
"%s = 0;"
%
rhstmp
)
code
.
funcstate
.
release_temp
(
rhstmp
)
...
...
Cython/Compiler/Optimize.py
View file @
d3c79c9b
...
...
@@ -152,12 +152,11 @@ class FinalOptimizePhase(Visitor.CythonTransform):
def
visit_SingleAssignmentNode
(
self
,
node
):
if
node
.
first
:
lhs
=
node
.
lhs
lhs
.
lhs_of_first_assignment
=
True
if
isinstance
(
lhs
,
ExprNodes
.
NameNode
)
and
lhs
.
entry
.
type
.
is_pyobject
:
# Have variable initialized to 0 rather than None
lhs
.
entry
.
init_to_none
=
False
lhs
.
entry
.
init
=
0
# Set a flag in NameNode to skip the decref
lhs
.
skip_assignment_decref
=
True
return
node
def
visit_SimpleCallNode
(
self
,
node
):
...
...
tests/errors/literal_lists.pyx
0 → 100644
View file @
d3c79c9b
def
f
():
cdef
int
*
p
if
False
:
p
=
[
1
,
2
,
3
]
_ERRORS
=
u"""
4:10: Literal list must be assigned to pointer at time of declaration
"""
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