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
7f36b856
Commit
7f36b856
authored
Jul 11, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consider void* the independent spanning type of any two incompatible pointer types
parent
8dabe05f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+3
-0
tests/run/pointers.pyx
tests/run/pointers.pyx
+27
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
7f36b856
...
@@ -3711,6 +3711,9 @@ def independent_spanning_type(type1, type2):
...
@@ -3711,6 +3711,9 @@ def independent_spanning_type(type1, type2):
return
py_object_type
return
py_object_type
span_type
=
_spanning_type
(
type1
,
type2
)
span_type
=
_spanning_type
(
type1
,
type2
)
if
span_type
is
None
:
if
span_type
is
None
:
if
type1
.
is_ptr
and
type2
.
is_ptr
:
# incompatible pointers, void* will do as a result
return
c_void_ptr_type
return
error_type
return
error_type
return
span_type
return
span_type
...
...
tests/run/pointers.pyx
View file @
7f36b856
cimport
cython
cdef
char
*
c_string
=
b'abcdefg'
cdef
char
*
c_string
=
b'abcdefg'
cdef
void
*
void_ptr
=
c_string
cdef
void
*
void_ptr
=
c_string
...
@@ -60,3 +61,29 @@ def bool_binop_truth(int x):
...
@@ -60,3 +61,29 @@ def bool_binop_truth(int x):
print
True
print
True
if
c_string
and
x
or
not
(
void_ptr
or
int_ptr
and
float_ptr
)
or
x
:
if
c_string
and
x
or
not
(
void_ptr
or
int_ptr
and
float_ptr
)
or
x
:
print
True
print
True
def
binop_voidptr
(
int
x
,
long
y
,
char
*
z
):
"""
>>> binop_voidptr(1, 3, b'abc')
'void *'
"""
result
=
&
x
and
&
y
and
z
return
cython
.
typeof
(
result
)
def
cond_expr_voidptr
(
int
x
,
long
y
,
char
*
z
):
"""
>>> cond_expr_voidptr(0, -1, b'abc')
('void *', 0)
>>> cond_expr_voidptr(-1, 0, b'abc')
('void *', -1)
>>> cond_expr_voidptr(-1, 0, b'')
('void *', 0)
>>> cond_expr_voidptr(0, -1, b'')
('void *', -1)
"""
result
=
&
x
if
len
(
z
)
else
&
y
assert
sizeof
(
long
)
>=
sizeof
(
int
)
assert
-
1
==
<
int
>
(
-
1L
)
return
cython
.
typeof
(
result
),
(
<
int
*>
result
)[
0
]
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