Add -Wimplicit-fallthrough checks if supported

Clang since r369414 (clang-10) can now check -Wimplicit-fallthrough for
C code, and use the GNU C style attribute to denote fallthrough.

Move the test from header only to autoconf. The previous test used
brittle version detection which did not work for newer clang that
supported this feature.

The attribute has to be its own statement, hence the added `;`. It also
can only precede case statements, so the final cases should be
explicitly terminated with break statements.

Fixes commit 3d29d11ac2 ("Clean compilation -Wextra")
Link: 1e0affb6e5
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
This commit is contained in:
Nick Desaulniers
2019-10-29 13:03:41 -07:00
committed by Qi Wang
parent a8b578d538
commit d01b425e5d
8 changed files with 68 additions and 44 deletions

View File

@@ -874,7 +874,7 @@ arena_decay_stashed(tsdn_t *tsdn, arena_t *arena,
arena, is_background_thread);
break;
}
/* Fall through. */
JEMALLOC_FALLTHROUGH;
case extent_state_muzzy:
extent_dalloc_wrapper(tsdn, arena, r_extent_hooks,
extent);

View File

@@ -135,10 +135,10 @@ malloc_strtoumax(const char *restrict nptr, char **restrict endptr, int base) {
break;
case '-':
neg = true;
/* Fall through. */
JEMALLOC_FALLTHROUGH;
case '+':
p++;
/* Fall through. */
JEMALLOC_FALLTHROUGH;
default:
goto label_prefix;
}
@@ -289,7 +289,7 @@ d2s(intmax_t x, char sign, char *s, size_t *slen_p) {
if (!neg) {
break;
}
/* Fall through. */
JEMALLOC_FALLTHROUGH;
case ' ':
case '+':
s--;

View File

@@ -389,7 +389,7 @@ tsd_cleanup(void *arg) {
* is still called for testing and completeness.
*/
assert_tsd_data_cleanup_done(tsd);
/* Fall through. */
JEMALLOC_FALLTHROUGH;
case tsd_state_nominal:
case tsd_state_nominal_slow:
tsd_do_data_cleanup(tsd);