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
Kirill Smelkov
cython
Commits
c612467a
Commit
c612467a
authored
May 26, 2020
by
Celelibi
Committed by
Stefan Behnel
May 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Emit an error when typeid() is used outside of C++ mode (GH-3637)
parent
d77f79c2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-0
tests/errors/e_cpp_only_features.pyx
tests/errors/e_cpp_only_features.pyx
+26
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
c612467a
...
@@ -10871,7 +10871,10 @@ class TypeidNode(ExprNode):
...
@@ -10871,7 +10871,10 @@ class TypeidNode(ExprNode):
typeinfo_entry
=
typeinfo_module
.
lookup
(
'type_info'
)
typeinfo_entry
=
typeinfo_module
.
lookup
(
'type_info'
)
return
PyrexTypes
.
CFakeReferenceType
(
PyrexTypes
.
c_const_type
(
typeinfo_entry
.
type
))
return
PyrexTypes
.
CFakeReferenceType
(
PyrexTypes
.
c_const_type
(
typeinfo_entry
.
type
))
cpp_message
=
'typeid operator'
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
self
.
cpp_check
(
env
)
type_info
=
self
.
get_type_info_type
(
env
)
type_info
=
self
.
get_type_info_type
(
env
)
if
not
type_info
:
if
not
type_info
:
self
.
error
(
"The 'libcpp.typeinfo' module must be cimported to use the typeid() operator"
)
self
.
error
(
"The 'libcpp.typeinfo' module must be cimported to use the typeid() operator"
)
...
...
tests/errors/e_cpp_only_features.pyx
0 → 100644
View file @
c612467a
# mode: error
# tag: no-cpp, werror
from
cython.operator
import
typeid
def
use_typeid
():
cdef
int
i
=
0
print
typeid
(
i
)
==
typeid
(
i
)
cdef
cppclass
A
:
pass
def
use_new
():
cdef
A
*
x
=
new
A
()
def
use_del
():
cdef
A
a
=
A
()
cdef
A
*
p
=
&
a
del
p
_ERRORS
=
"""
8:10: typeid operator only allowed in c++
8:23: typeid operator only allowed in c++
14:20: Operation only allowed in c++
19:4: Operation only allowed in c++
"""
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