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
8a44e54c
Commit
8a44e54c
authored
Apr 09, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 158 to ignore extern redeclarations.
parent
bd50b31c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+10
-10
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
8a44e54c
...
...
@@ -659,7 +659,6 @@ class DecoratorTransform(CythonTransform, SkipDeclarations):
return
[
func_node
,
reassignment
]
ERR_DEC_AFTER
=
"cdef variable '%s' declared after it is used"
class
AnalyseDeclarationsTransform
(
CythonTransform
):
basic_property
=
TreeFragment
(
u"""
...
...
@@ -673,22 +672,22 @@ property NAME:
def
__call__
(
self
,
root
):
self
.
env_stack
=
[
root
.
scope
]
# needed to determine if a cdef var is declared after it's used.
self
.
local_scope
_stack
=
[]
self
.
seen_vars
_stack
=
[]
return
super
(
AnalyseDeclarationsTransform
,
self
).
__call__
(
root
)
def
visit_NameNode
(
self
,
node
):
self
.
local_scope
_stack
[
-
1
].
add
(
node
.
name
)
self
.
seen_vars
_stack
[
-
1
].
add
(
node
.
name
)
return
node
def
visit_ModuleNode
(
self
,
node
):
self
.
local_scope
_stack
.
append
(
set
())
self
.
seen_vars
_stack
.
append
(
set
())
node
.
analyse_declarations
(
self
.
env_stack
[
-
1
])
self
.
visitchildren
(
node
)
self
.
local_scope
_stack
.
pop
()
self
.
seen_vars
_stack
.
pop
()
return
node
def
visit_FuncDefNode
(
self
,
node
):
self
.
local_scope
_stack
.
append
(
set
())
self
.
seen_vars
_stack
.
append
(
set
())
lenv
=
node
.
create_local_scope
(
self
.
env_stack
[
-
1
])
node
.
body
.
analyse_control_flow
(
lenv
)
# this will be totally refactored
node
.
declare_arguments
(
lenv
)
...
...
@@ -703,7 +702,7 @@ property NAME:
self
.
env_stack
.
append
(
lenv
)
self
.
visitchildren
(
node
)
self
.
env_stack
.
pop
()
self
.
local_scope
_stack
.
pop
()
self
.
seen_vars
_stack
.
pop
()
return
node
# Some nodes are no longer needed after declaration
...
...
@@ -728,9 +727,10 @@ property NAME:
return
None
def
visit_CNameDeclaratorNode
(
self
,
node
):
if
node
.
name
in
self
.
local_scope_stack
[
-
1
]:
# cdef variable declared after it's used.
error
(
node
.
pos
,
ERR_DEC_AFTER
%
node
.
name
)
if
node
.
name
in
self
.
seen_vars_stack
[
-
1
]:
entry
=
self
.
env_stack
[
-
1
].
lookup
(
node
.
name
)
if
entry
is
None
or
entry
.
visibility
!=
'extern'
:
error
(
node
.
pos
,
"cdef variable '%s' declared after it is used"
%
node
.
name
)
self
.
visitchildren
(
node
)
return
node
...
...
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