-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Enable -Wimplicit-fallthrough compiler warning #6252
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
Conversation
05e1d65
to
25b345a
Compare
2024e23
to
4c8f0fd
Compare
I'm a bit concerned about the annoyance this could cause for extensions... especially as they wouldn't have the macro available on old PHP versions. |
Right, we could potentially lower the level from 3 (the default) to 1 which accepts any comment as a fall-through comment. I suppose amending the skeleton to also generate the macro is the version is less than PHP 8.1 /undef is also an option but that wouldn't help already existing extensions :-/ |
That sounds like a good approach to me. |
4c8f0fd
to
5fe6948
Compare
8023794
to
4608151
Compare
f6804c1
to
1a7aca6
Compare
Hopefully everything should work now, and the decision to use level 1 accepts any comment as a switch case fallthrough comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please commit the addition of ZEND_FALLTHROUGH and all its uses, and only leave the build system changes that enable the warning in this PR?
ext/session/tests/session_test_936e28c2e65332e2525cabe7864a6e66
Outdated
Show resolved
Hide resolved
55d0488
to
f6f842b
Compare
azure/configure.yml
Outdated
@@ -66,7 +66,6 @@ steps: | |||
--with-pdo-dblib \ | |||
--with-pdo-oci=shared,instantclient,/opt/oracle/instantclient \ | |||
--with-oci8=shared,instantclient,/opt/oracle/instantclient \ | |||
--enable-werror \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be dropped now.
Build failure on i386, should exclude pcre2lib. |
Actually, the pcre failure should be resolved with |
89cf484
to
b8c6f99
Compare
main/streams/plain_wrapper.c
Outdated
@@ -918,7 +918,8 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void | |||
case PHP_STREAM_SYNC_FDSYNC: | |||
return php_stdiop_sync(stream, 1) == 0 ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR; | |||
} | |||
|
|||
/* TODO Should this fallthrough? */ | |||
ZEND_FALLTHROUGH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should return PHP_STREAM_OPTION_RETURN_NOTIMPL
here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might indeed be correct, I was just surprised that CI was failing because of this, so I made a quick commit adding this to see if there are any other ones.
Seems this is the last one which is also finding an actual bug :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe even PHP_STREAM_OPTION_RETURN_ERR
, as this means an incorrect option value was passed.
Otherwise this falls through to the next case statement.
And add it back to ext/date, ext/hash, and ext/opcache
b8c6f99
to
35d8051
Compare
This is a sync of the php#6252 after few years: - ext/date: fixed since derickr/timelib@f8caaef - ext/hash: warning happens only on 32-bit build in ext/hash/sha3/generic32lc/KeccakP-1600-inplace32BI.c - ext/opcache: IR JIT doesn't seem to have this issue - ext/pcre remains disabled due to pcre2lib/sljit/sljitNativeARM_64.c
This is a sync of the php#6252 after few years: - ext/date: fixed since derickr/timelib@f8caaef - ext/hash: warning happens only on 32-bit build in ext/hash/sha3/generic32lc/KeccakP-1600-inplace32BI.c - ext/opcache: IR JIT doesn't seem to have this issue - ext/pcre remains disabled due to pcre2lib/sljit/sljitNativeARM_64.c
This is a sync of the #6252 after few years: - ext/date: pending recheck in GH-14187 - ext/hash: warning happens only on 32-bit build in ext/hash/sha3/generic32lc/KeccakP-1600-inplace32BI.c - ext/opcache: IR JIT doesn't seem to have this issue - ext/pcre remains disabled due to pcre2lib/sljit/sljitNativeARM_64.c (should be rechecked and fixed upstream)
Introduce a pseudo-keyword
fallthrough
(following the Linux Kernal style) to indicate that a switch case fall-through to the following one.This has a couple of benefits in that it normalizes our fall-through comments (which have various formulation even within the same file) and let's use enable
-Wimplicit-fallthrough=3
which is included in-Wextra
.I enabled level 5 temporarily (which disables all comments) to use the newly introduce pseudo-keyword instead of comments in extension code under our control.
A couple of issues remain:
/* fallthrough */
comment in an instance or we suppress this warning for DateTime