libc: enable -Wimplicit-fallthrough
libc had some -Wimplicit-fallthrough warnings. They all seem to be
benign. We're trying to enable this flag globally, so we need to
annotate these breaks here.
Bug: 112564944
Test: Builds
Change-Id: I5afae694cc4cf26ad1a61e2c8ae91f00cda7c733
diff --git a/libc/private/bionic_macros.h b/libc/private/bionic_macros.h
index 979a704..0a36cdb 100644
--- a/libc/private/bionic_macros.h
+++ b/libc/private/bionic_macros.h
@@ -94,4 +94,12 @@
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
+// Used to inform clang's -Wimplicit-fallthrough that a fallthrough is intended. There's no way to
+// silence (or enable, apparently) -Wimplicit-fallthrough in C yet.
+#ifdef __cplusplus
+#define __BIONIC_FALLTHROUGH [[clang::fallthrough]]
+#else
+#define __BIONIC_FALLTHROUGH
+#endif
+
#endif // _BIONIC_MACROS_H_