]> Savannah Git Hosting - gnulib.git/commitdiff
regex: work with GCC7's -Werror=implicit-fallthrough=
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 26 Jul 2017 16:12:29 +0000 (09:12 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 26 Jul 2017 16:13:07 +0000 (09:13 -0700)
* lib/regex_internal.h (FALLTHROUGH): New macro.
* lib/regcomp.c (peek_token_bracket, parse_expression):
* lib/regexec.c (check_node_accept): Use it.

ChangeLog
lib/regcomp.c
lib/regex_internal.h
lib/regexec.c

index ae2b049b41519683ddc9e5128924e389e3980667..d53d143a136868c90c6fc5ad4bb7a55c2e36714e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-07-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+       regex: work with GCC7's -Werror=implicit-fallthrough=
+       * lib/regex_internal.h (FALLTHROUGH): New macro.
+       * lib/regcomp.c (peek_token_bracket, parse_expression):
+       * lib/regexec.c (check_node_accept): Use it.
+
 2017-07-24  Paul Eggert  <eggert@cs.ucla.edu>
 
        fts: simplify fts_build
index 9fd4fed99943ede3e23899e032b57e6a01032618..282452121327968bcbae5edccc2847f509443b06 100644 (file)
@@ -2078,16 +2078,18 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
        case '.':
          token->type = OP_OPEN_COLL_ELEM;
          break;
+
        case '=':
          token->type = OP_OPEN_EQUIV_CLASS;
          break;
+
        case ':':
          if (syntax & RE_CHAR_CLASSES)
            {
              token->type = OP_OPEN_CHAR_CLASS;
              break;
            }
-         /* else fall through.  */
+         FALLTHROUGH;
        default:
          token->type = CHARACTER;
          token->opr.c = c;
@@ -2289,16 +2291,19 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
        }
 #endif
       break;
+
     case OP_OPEN_SUBEXP:
       tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
       if (BE (*err != REG_NOERROR && tree == NULL, 0))
        return NULL;
       break;
+
     case OP_OPEN_BRACKET:
       tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
       if (BE (*err != REG_NOERROR && tree == NULL, 0))
        return NULL;
       break;
+
     case OP_BACK_REF:
       if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1))
        {
@@ -2315,13 +2320,14 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
       ++dfa->nbackref;
       dfa->has_mb_node = 1;
       break;
+
     case OP_OPEN_DUP_NUM:
       if (syntax & RE_CONTEXT_INVALID_DUP)
        {
          *err = REG_BADRPT;
          return NULL;
        }
-      /* FALLTHROUGH */
+      FALLTHROUGH;
     case OP_DUP_ASTERISK:
     case OP_DUP_PLUS:
     case OP_DUP_QUESTION:
@@ -2335,7 +2341,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
          fetch_token (token, regexp, syntax);
          return parse_expression (regexp, preg, token, syntax, nest, err);
        }
-      /* else fall through  */
+      FALLTHROUGH;
     case OP_CLOSE_SUBEXP:
       if ((token->type == OP_CLOSE_SUBEXP) &&
          !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
@@ -2343,7 +2349,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
          *err = REG_ERPAREN;
          return NULL;
        }
-      /* else fall through  */
+      FALLTHROUGH;
     case OP_CLOSE_DUP_NUM:
       /* We treat it as a normal character.  */
 
@@ -2358,6 +2364,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
          return NULL;
        }
       break;
+
     case ANCHOR:
       if ((token->opr.ctx_type
           & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST))
@@ -2402,6 +2409,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
             it must not be "<ANCHOR(^)><REPEAT(*)>".  */
       fetch_token (token, regexp, syntax);
       return tree;
+
     case OP_PERIOD:
       tree = create_token_tree (dfa, NULL, NULL, token);
       if (BE (tree == NULL, 0))
@@ -2412,6 +2420,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
       if (dfa->mb_cur_max > 1)
        dfa->has_mb_node = 1;
       break;
+
     case OP_WORD:
     case OP_NOTWORD:
       tree = build_charclass_op (dfa, regexp->trans,
@@ -2421,6 +2430,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
       if (BE (*err != REG_NOERROR && tree == NULL, 0))
        return NULL;
       break;
+
     case OP_SPACE:
     case OP_NOTSPACE:
       tree = build_charclass_op (dfa, regexp->trans,
@@ -2430,12 +2440,15 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
       if (BE (*err != REG_NOERROR && tree == NULL, 0))
        return NULL;
       break;
+
     case OP_ALT:
     case END_OF_RE:
       return NULL;
+
     case BACK_SLASH:
       *err = REG_EESCAPE;
       return NULL;
+
     default:
       /* Must not happen?  */
 #ifdef DEBUG
index 827020719c5bd5b98789427c88e64d16294cd606..d7f76d6d8fdd7aed314b6aeb52006221c1bb507c 100644 (file)
@@ -899,4 +899,12 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
 # define __attribute_warn_unused_result__ /* empty */
 #endif
 
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
 #endif /*  _REGEX_INTERNAL_H */
index ef52b243ad74710c3db350eaefbf20d8dd485a2e..497ba0f31d4375b18ae03c7544a58a581bc88712 100644 (file)
@@ -4078,7 +4078,7 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
     case OP_UTF8_PERIOD:
       if (ch >= ASCII_CHARS)
         return false;
-      /* FALLTHROUGH */
+      FALLTHROUGH;
 #endif
     case OP_PERIOD:
       if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))