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
Xavier Thompson
cython
Commits
e42f3a8c
Commit
e42f3a8c
authored
Sep 11, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect const-correctness errors involving cypclasses
parent
9c5ad7a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
1 deletion
+26
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+26
-1
No files found.
Cython/Compiler/PyrexTypes.py
View file @
e42f3a8c
...
...
@@ -4465,7 +4465,6 @@ class CypClassType(CppClassType):
return
self
.
_assign_from_py_code
(
source_code
,
result_code
,
error_pos
,
code
,
from_py_function
,
error_condition
,
extra_args
=
extra_args
)
def
empty_declaration_code
(
self
):
if
self
.
_empty_declaration
is
None
:
self
.
_empty_declaration
=
self
.
declaration_code
(
''
,
deref
=
1
)
...
...
@@ -4490,7 +4489,14 @@ class CypClassType(CppClassType):
def
dynamic_cast_code
(
self
,
expr_code
):
return
"dynamic_cast<%s>(%s)"
%
(
self
.
declaration_code
(
''
),
expr_code
)
def
same_as_resolved_type
(
self
,
other_type
):
if
other_type
.
is_const_cyp_class
:
return
0
return
super
(
CypClassType
,
self
).
same_as_resolved_type
(
other_type
)
def
assignable_from_resolved_type
(
self
,
other_type
):
if
other_type
.
is_const_cyp_class
:
return
0
if
other_type
.
is_ptr
and
other_type
.
base_type
.
is_cpp_class
and
other_type
.
base_type
.
is_subclass
(
self
)
or
other_type
.
is_null_ptr
:
return
1
return
super
(
CypClassType
,
self
).
assignable_from_resolved_type
(
other_type
)
...
...
@@ -4580,6 +4586,12 @@ class ConstCypclassType(BaseType):
self
.
_empty_declaration
=
"const %s"
%
self
.
const_base_type
.
empty_declaration_code
()
return
self
.
_empty_declaration
def
resolve
(
self
):
base_type
=
self
.
const_base_type
.
resolve
()
if
base_type
==
self
.
const_base_type
:
return
self
return
ConstCypclassType
(
base_type
)
def
specialize
(
self
,
values
):
base_type
=
self
.
const_base_type
.
specialize
(
values
)
if
base_type
==
self
.
const_base_type
:
...
...
@@ -4603,6 +4615,19 @@ class ConstCypclassType(BaseType):
self
.
to_py_function
=
self
.
const_base_type
.
to_py_function
return
True
def
assignable_from
(
self
,
src_type
):
return
self
.
assignable_from_resolved_type
(
src_type
.
resolve
())
def
assignable_from_resolved_type
(
self
,
src_type
):
if
src_type
.
is_const_cyp_class
:
src_type
=
src_type
.
const_base_type
return
self
.
const_base_type
.
assignable_from_resolved_type
(
src_type
)
def
same_as
(
self
,
other_type
):
if
not
other_type
.
is_const_cyp_class
:
return
0
return
self
.
same_as_resolved_type
(
other_type
.
resolve
())
def
same_as_resolved_type
(
self
,
other_type
):
if
other_type
.
is_const_cyp_class
:
return
self
.
const_base_type
.
same_as_resolved_type
(
other_type
.
const_base_type
)
...
...
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