Looking through the FALLTHROUGH definitions in gnulib, it appears that it has the assumption built-in that glibc will only be built by GCC.
Nowadays people are alternatively using (non-Apple) clang to build glibc, see https://www.collabora.com/news-and-blog/blog/2021/09/30/a-tale-of-two-toolchains-and-glibc/ https://www.collabora.com/news-and-blog/blog/2023/01/17/a-brave-new-world-building-glibc-with-llvm/ To help going in this direction, how about this patch? Paul, do you object? 2023-02-26 Bruno Haible <br...@clisp.org> Support FALLTHROUGH macro better in glibc+clang. * lib/fnmatch.c (FALLTHROUGH): Use __attribute__ ((__fallthrough__)) also in clang >= 10. * lib/fts.c (FALLTHROUGH): Likewise. * lib/regex_internal.h (FALLTHROUGH): Likewise. diff --git a/lib/fnmatch.c b/lib/fnmatch.c index 7c9c4e0f24..306b967c62 100644 --- a/lib/fnmatch.c +++ b/lib/fnmatch.c @@ -64,7 +64,7 @@ extern int fnmatch (const char *pattern, const char *string, int flags); #endif #ifdef _LIBC -# if __GNUC__ >= 7 +# if (__GNUC__ >= 7) || (__clang_major__ >= 10) # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0) diff --git a/lib/fts.c b/lib/fts.c index 78584b2902..388d251252 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -203,7 +203,7 @@ enum Fts_stat #endif #ifdef _LIBC -# if __GNUC__ >= 7 +# if (__GNUC__ >= 7) || (__clang_major__ >= 10) # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0) diff --git a/lib/regex_internal.h b/lib/regex_internal.h index 149ec2e868..d4dae98534 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -822,7 +822,7 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx) } #ifdef _LIBC -# if __GNUC__ >= 7 +# if (__GNUC__ >= 7) || (__clang_major__ >= 10) # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0)