From ea6155677e0f466d05a0027fdbe29827f4a08c2c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 2 Jun 2021 14:09:18 -0400 Subject: Enable -Wimplicit-fallthrough --- util.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'util.h') diff --git a/util.h b/util.h index 1b52513..7b8b877 100644 --- a/util.h +++ b/util.h @@ -42,6 +42,12 @@ # define BFS_HAS_INCLUDE(header, fallback) fallback #endif +#ifdef __has_c_attribute +# define BFS_HAS_C_ATTRIBUTE(attr) __has_c_attribute(attr) +#else +# define BFS_HAS_C_ATTRIBUTE(attr) false +#endif + #ifndef BFS_HAS_MNTENT # define BFS_HAS_MNTENT BFS_HAS_INCLUDE(, __GLIBC__) #endif @@ -86,6 +92,14 @@ # define O_DIRECTORY 0 #endif +#if BFS_HAS_C_ATTRIBUTE(fallthrough) +# define fallthrough [[fallthrough]] +#elif __GNUC__ +# define fallthrough __attribute__((fallthrough)) +#else +# define fallthrough +#endif + /** * Adds compiler warnings for bad printf()-style function calls, if supported. */ -- cgit v1.2.3