Skip to content

Conversation

@vstinner
Copy link
Member

@vstinnervstinner 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
MemberAuthor

cc @sobolevn

Copy link
Member

@sobolevnsobolevn 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) :)

@vstinner
Copy link
MemberAuthor

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

Done.

@mdboom
Copy link
Contributor

Maybe of interest to @nohlson.

No longer define __has_attribute() if it's not defined. Move also _Py__has_builtin() at the top of pyport.h.
Copy link
Member

@ericsnowcurrentlyericsnowcurrently 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.

@vstinnervstinner enabled auto-merge (squash) June 27, 2024 09:38
@vstinner
Copy link
MemberAuthor

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

@vstinnervstinner merged commit 12af8ec into python:mainJun 27, 2024
@vstinnervstinner 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 <mail@sobolevn.me>
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 <mail@sobolevn.me>
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 <mail@sobolevn.me>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@vstinner@mdboom@ericsnowcurrently@sobolevn@corona10@AlexWaygood