summaryrefslogtreecommitdiff
path: root/src/system.h
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2017-05-21 09:23:18 -0700
committerJim Meyering <meyering@fb.com>2017-05-21 12:07:57 -0700
commit1e1e23358050f201f5630a16609c441b9e7955a0 (patch)
tree647047b09474367701bfc1a8b45c4907145aceee /src/system.h
parent9e2c89397916d9587f1945528eb5d5651c0b4edb (diff)
downloadgrep-1e1e23358050f201f5630a16609c441b9e7955a0.tar.gz
maint: accommodate GCC7's -Werror=duplicated-branches
* src/system.h (IGNORE_DUPLICATE_BRANCH_WARNING): Define. * src/grep.c (grepfile): Use it. * src/kwset.c (bmexec, acexec): Use it.
Diffstat (limited to 'src/system.h')
-rw-r--r--src/system.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/system.h b/src/system.h
index f9747935..bac78235 100644
--- a/src/system.h
+++ b/src/system.h
@@ -115,4 +115,18 @@ __asan_unpoison_memory_region (void const volatile *addr, size_t size) { }
# endif
#endif
+/* When we deliberately use duplicate branches, use this macro to
+ disable gcc's -Wduplicated-branches in the containing expression. */
+#if 7 <= __GNUC__
+# define IGNORE_DUPLICATE_BRANCH_WARNING(exp) \
+ ({ \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wduplicated-branches\"") \
+ exp; \
+ _Pragma ("GCC diagnostic pop") \
+ })
+#else
+# define IGNORE_DUPLICATE_BRANCH_WARNING(exp) exp
+#endif
+
#endif