Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-121040: Use __attribute__((fallthrough)) #121044

Merged
merged 6 commits into from
Jun 27, 2024
Merged

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 26, 2024

Annotate explicitly "fall through" switch cases with a new _Py_FALLTHROUGH macro which uses attribute((fallthrough)) if available.

Fix warnings when using -Wimplicit-fallthrough compiler flag.

Annotate explicitly "fall through" switch cases with a new
_Py_FALLTHROUGH macro which uses __attribute__((fallthrough)) if
available.

Fix warnings when using -Wimplicit-fallthrough compiler flag.
@vstinner
Copy link
Member Author

cc @sobolevn

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you need to run make regen-cases (or maybe even make regen-all) :)

Include/pyport.h Outdated Show resolved Hide resolved
@vstinner
Copy link
Member Author

Looks like you need to run make regen-cases (or maybe even make regen-all) :)

Done.

@mdboom
Copy link
Contributor

mdboom commented Jun 26, 2024

Maybe of interest to @nohlson.

Include/pyport.h Outdated Show resolved Hide resolved
No longer define __has_attribute() if it's not defined.

Move also _Py__has_builtin() at the top of pyport.h.
Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I left one small comment where you might consider a slightly different spelling, but I'll leave that up to you.

Python/pyhash.c Show resolved Hide resolved
@brettcannon brettcannon removed their request for review June 26, 2024 17:35
@vstinner vstinner enabled auto-merge (squash) June 27, 2024 09:38
@vstinner
Copy link
Member Author

I tested my change with -Wimplicit-fallthrough=5 which ignores all comments. There are only remaining comments on Modules/expat/ when --with-system-expat is not used, not in the Python code base anymore.

See also the article about the flag: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7

@vstinner vstinner merged commit 12af8ec into python:main Jun 27, 2024
54 checks passed
@vstinner vstinner deleted the fallthrough branch June 27, 2024 09:58
mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
Fix warnings when using -Wimplicit-fallthrough compiler flag.

Annotate explicitly "fall through" switch cases with a new
_Py_FALLTHROUGH macro which uses __attribute__((fallthrough)) if
available. Replace "fall through" comments with _Py_FALLTHROUGH.

Add _Py__has_attribute() macro. No longer define __has_attribute()
macro if it's not defined. Move also _Py__has_builtin() at the top
of pyport.h.

Co-Authored-By: Nikita Sobolev <[email protected]>
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
Fix warnings when using -Wimplicit-fallthrough compiler flag.

Annotate explicitly "fall through" switch cases with a new
_Py_FALLTHROUGH macro which uses __attribute__((fallthrough)) if
available. Replace "fall through" comments with _Py_FALLTHROUGH.

Add _Py__has_attribute() macro. No longer define __has_attribute()
macro if it's not defined. Move also _Py__has_builtin() at the top
of pyport.h.

Co-Authored-By: Nikita Sobolev <[email protected]>
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
Fix warnings when using -Wimplicit-fallthrough compiler flag.

Annotate explicitly "fall through" switch cases with a new
_Py_FALLTHROUGH macro which uses __attribute__((fallthrough)) if
available. Replace "fall through" comments with _Py_FALLTHROUGH.

Add _Py__has_attribute() macro. No longer define __has_attribute()
macro if it's not defined. Move also _Py__has_builtin() at the top
of pyport.h.

Co-Authored-By: Nikita Sobolev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants