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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
10b6817e
Commit
10b6817e
authored
Jul 08, 2017
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First attempt at explicit fallthrough annotation.
parent
e8a178e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+4
-0
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+21
-0
No files found.
Cython/Compiler/Nodes.py
View file @
10b6817e
...
...
@@ -3623,6 +3623,7 @@ class DefNodeWrapper(FuncDefNode):
if
i
>=
min_positional_args
-
1
:
code
.
put
(
'case %2d: '
%
(
i
+
1
))
code
.
putln
(
"values[%d] = PyTuple_GET_ITEM(%s, %d);"
%
(
i
,
Naming
.
args_cname
,
i
))
code
.
putln
(
'CYTHON_FALLTHROUGH'
)
if
min_positional_args
==
0
:
code
.
put
(
'case 0: '
)
code
.
putln
(
'break;'
)
...
...
@@ -3749,6 +3750,7 @@ class DefNodeWrapper(FuncDefNode):
code
.
put
(
'case %2d: '
%
(
i
+
1
))
code
.
putln
(
"values[%d] = PyTuple_GET_ITEM(%s, %d);"
%
(
i
,
Naming
.
args_cname
,
i
))
code
.
putln
(
'CYTHON_FALLTHROUGH'
)
code
.
putln
(
'case 0: break;'
)
if
not
self
.
star_arg
:
code
.
put
(
'default: '
)
# more arguments than allowed
...
...
@@ -3817,6 +3819,8 @@ class DefNodeWrapper(FuncDefNode):
self
.
name
,
pystring_cname
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
'}'
)
if
max_positional_args
>
0
and
i
<
last_required_arg
:
code
.
putln
(
'CYTHON_FALLTHROUGH'
)
if
max_positional_args
>
0
:
code
.
putln
(
'}'
)
...
...
Cython/Utility/ModuleSetupCode.c
View file @
10b6817e
...
...
@@ -356,6 +356,14 @@
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) 0
#endif
// backport of PyAsyncMethods from Py3.5 to older Py3.x versions
// (mis-)using the "tp_reserved" type slot which is re-activated as "tp_as_async" in Py3.5
#if CYTHON_USE_ASYNC_SLOTS
...
...
@@ -434,6 +442,19 @@
#include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
#if __has_cpp_attribute(fallthrough)
#define CYTHON_FALLTHROUGH [[fallthrough]]
#elif __has_cpp_attribute(clang::fallthrough)
#define CYTHON_FALLTHROUGH [[clang::fallthrough]]
#elif __has_attribute(fallthrough) || (defined(__GNUC__) && defined(__attribute__))
#define CYTHON_FALLTHROUGH __attribute__((fallthrough))
#else
#define CYTHON_FALLTHROUGH
#endif
#endif
/////////////// CInitCode ///////////////
// inline attribute
...
...
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