diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2021-06-02 14:09:18 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2021-06-02 14:09:18 -0400 |
commit | ea6155677e0f466d05a0027fdbe29827f4a08c2c (patch) | |
tree | d2b8ab2d6f8921d6e5ad29b4fb58368533a0c02b /util.h | |
parent | 69a5227098b87b048a90ceb1ca7b169c02ba151e (diff) | |
download | bfs-ea6155677e0f466d05a0027fdbe29827f4a08c2c.tar.xz |
Enable -Wimplicit-fallthrough
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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(<mntent.h>, __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. */ |