From: H.J. Lu Date: Sun, 22 Dec 2024 21:12:00 +0000 (+0800) Subject: Suppress Clang -Wimplicit-fallthrough warnings X-Git-Tag: glibc-2.41~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0813cb584731c2df3c37bb3e3631ef37a821d599;p=thirdparty%2Fglibc.git Suppress Clang -Wimplicit-fallthrough warnings Since Clang doesn't properly handle /* FALLTHROUGH */ in elf/tst-align2.c nor /* fall through */ in misc/tst-tsearch.c tst-align2.c:100:9: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] 100 | case 'A': | ^ tst-align2.c:100:9: note: insert '__attribute__((fallthrough));' to silence this warning 100 | case 'A': | ^ | __attribute__((fallthrough)); tst-align2.c:100:9: note: insert 'break;' to avoid fall-through 100 | case 'A': | ^ | break; suppress them when compiled with Clang. Signed-off-by: H.J. Lu Reviewed-by: Sam James --- diff --git a/elf/tst-align2.c b/elf/tst-align2.c index c73ea5a5fe..c49ed70c17 100644 --- a/elf/tst-align2.c +++ b/elf/tst-align2.c @@ -22,6 +22,7 @@ #include #include #include +#include static int res, fds[2], result; static bool test_destructors; @@ -91,6 +92,8 @@ do_test (void) int des_seen = 0, dso_des_seen = 0; while ((len = TEMP_FAILURE_RETRY (read (fds[0], &c, 1))) > 0) { + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (3.2, "-Wimplicit-fallthrough"); switch (c) { case 'B': @@ -112,6 +115,7 @@ do_test (void) result = 1; break; } + DIAG_POP_NEEDS_COMMENT_CLANG; } close (fds[0]); diff --git a/misc/tst-tsearch.c b/misc/tst-tsearch.c index 2ca561dd7d..2a8f13f774 100644 --- a/misc/tst-tsearch.c +++ b/misc/tst-tsearch.c @@ -26,6 +26,7 @@ #include #include #include +#include #define SEED 0 #define BALANCED 1 @@ -286,6 +287,8 @@ mangle_tree (enum order how, enum action what, void **root, int lag) abort (); } + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (3.2, "-Wimplicit-fallthrough"); switch (what) { case build_and_del: @@ -331,6 +334,7 @@ mangle_tree (enum order how, enum action what, void **root, int lag) break; } + DIAG_POP_NEEDS_COMMENT_CLANG; } }