summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2021-06-02 14:09:18 -0400
committerTavian Barnes <tavianator@tavianator.com>2021-06-02 14:09:18 -0400
commitea6155677e0f466d05a0027fdbe29827f4a08c2c (patch)
treed2b8ab2d6f8921d6e5ad29b4fb58368533a0c02b /util.h
parent69a5227098b87b048a90ceb1ca7b169c02ba151e (diff)
downloadbfs-ea6155677e0f466d05a0027fdbe29827f4a08c2c.tar.xz
Enable -Wimplicit-fallthrough
Diffstat (limited to 'util.h')
-rw-r--r--util.h14
1 files changed, 14 insertions, 0 deletions
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(<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.
*/