summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2017-05-20 17:45:36 -0700
committerJim Meyering <meyering@fb.com>2017-05-21 12:07:57 -0700
commit9e2c89397916d9587f1945528eb5d5651c0b4edb (patch)
tree0fee709df6d293cae8499cc6b7d9795ea8715450 /src
parentef5f4ace94af183cc8673520c4dac1aad8fbf30f (diff)
downloadgrep-9e2c89397916d9587f1945528eb5d5651c0b4edb.tar.gz
maint: update to work with GCC7's -Werror=implicit-fallthrough=
* src/system.h (FALLTHROUGH): Define. * src/grep.c (context_length_arg): Use new FALLTHROUGH macro in place of comments (fgrep_to_grep_pattern, try_fgrep_pattern, main): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/grep.c10
-rw-r--r--src/system.h8
2 files changed, 13 insertions, 5 deletions
diff --git a/src/grep.c b/src/grep.c
index 775f227d..1958e264 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -759,7 +759,7 @@ context_length_arg (char const *str, intmax_t *out)
case LONGINT_OVERFLOW:
if (0 <= *out)
break;
- /* Fall through. */
+ FALLTHROUGH;
default:
die (EXIT_TROUBLE, 0, "%s: %s", str,
_("invalid context length argument"));
@@ -2308,7 +2308,7 @@ fgrep_to_grep_pattern (char **keys_p, size_t *len_p)
{
case (size_t) -2:
n = len;
- /* Fall through. */
+ FALLTHROUGH;
default:
p = mempcpy (p, keys, n);
break;
@@ -2316,7 +2316,7 @@ fgrep_to_grep_pattern (char **keys_p, size_t *len_p)
case (size_t) -1:
memset (&mb_state, 0, sizeof mb_state);
n = 1;
- /* Fall through. */
+ FALLTHROUGH;
case 1:
switch (*keys)
{
@@ -2376,7 +2376,7 @@ try_fgrep_pattern (int matcher, char *keys, size_t *len_p)
case '(': case '+': case '?': case '{': case '|':
if (matcher == G_MATCHER_INDEX)
goto fail;
- /* Fall through. */
+ FALLTHROUGH;
default:
q++, len--;
break;
@@ -2653,7 +2653,7 @@ main (int argc, char **argv)
case 'R':
fts_options = basic_fts_options | FTS_LOGICAL;
- /* Fall through. */
+ FALLTHROUGH;
case 'r':
directories = RECURSE_DIRECTORIES;
last_recursive = prev_optind;
diff --git a/src/system.h b/src/system.h
index 6292a287..f9747935 100644
--- a/src/system.h
+++ b/src/system.h
@@ -107,4 +107,12 @@ static _GL_UNUSED void
__asan_unpoison_memory_region (void const volatile *addr, size_t size) { }
#endif
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
#endif