2016-07-11  Marek Polacek  <pola...@redhat.com>

        PR c/7652
        * internal.h (CPP_FALLTHRU): Define.
        * expr.c (_cpp_parse_expr): Use CPP_FALLTHRU.
        * lex.c (search_line_fast): Likewise.
        (lex_raw_string): Likewise.
        (_cpp_lex_direct): Likewise.
        (cpp_token_val_index): Likewise.
        * macro.c (parse_params): Likewise.
        * pch.c (write_macdef): Likewise.
        (count_defs): Likewise.
        (write_defs): Likewise.

diff --git gcc/libcpp/expr.c gcc/libcpp/expr.c
index 5cdca6f..361e157 100644
--- gcc/libcpp/expr.c
+++ gcc/libcpp/expr.c
@@ -1311,6 +1311,7 @@ _cpp_parse_expr (cpp_reader *pfile, bool is_if)
            pfile->state.skip_eval++;
          else
            pfile->state.skip_eval--;
+         CPP_FALLTHRU ();
        default:
          break;
        }
diff --git gcc/libcpp/internal.h gcc/libcpp/internal.h
index ca2b498..32aba40 100644
--- gcc/libcpp/internal.h
+++ gcc/libcpp/internal.h
@@ -78,6 +78,12 @@ struct cset_converter
    efficiency, and partly to limit runaway recursion.  */
 #define CPP_STACK_MAX 200
 
+#if __GNUC__ >= 7
+# define CPP_FALLTHRU() __builtin_fallthrough ()
+#else
+# define CPP_FALLTHRU()
+#endif
+
 /* Host alignment handling.  */
 struct dummy
 {
diff --git gcc/libcpp/lex.c gcc/libcpp/lex.c
index 236418d..ed884a4 100644
--- gcc/libcpp/lex.c
+++ gcc/libcpp/lex.c
@@ -610,6 +610,7 @@ search_line_fast (const uchar *s, const uchar *end 
ATTRIBUTE_UNUSED)
        if (l != 0)
          break;
        s += sizeof(unsigned long);
+       CPP_FALLTHRU ();
       case 2:
        l = u.l[i++];
        if (l != 0)
@@ -1574,6 +1575,7 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, 
const uchar *base,
              BUF_APPEND (base, cur - base);
              base = cur;
              BUF_APPEND ("\\", 1);
+             CPP_FALLTHRU ();
            after_backslash:
              if (note->type == ' ')
                {
@@ -2415,6 +2417,7 @@ _cpp_lex_direct (cpp_reader *pfile)
            }
        }
       /* Fall through.  */
+      CPP_FALLTHRU ();
 
     case '_':
     case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
@@ -2717,6 +2720,8 @@ _cpp_lex_direct (cpp_reader *pfile)
          }
        buffer->cur++;
       }
+      /* XXX Really fallthru?  */
+      CPP_FALLTHRU ();
 
     default:
       create_literal (pfile, result, buffer->cur - 1, 1, CPP_OTHER);
@@ -3323,6 +3328,7 @@ cpp_token_val_index (const cpp_token *tok)
       else if (tok->type == CPP_PRAGMA)
        return CPP_TOKEN_FLD_PRAGMA;
       /* else fall through */
+      CPP_FALLTHRU ();
     default:
       return CPP_TOKEN_FLD_NONE;
     }
diff --git gcc/libcpp/macro.c gcc/libcpp/macro.c
index a3b8348..c2c0de4 100644
--- gcc/libcpp/macro.c
+++ gcc/libcpp/macro.c
@@ -2886,6 +2886,7 @@ parse_params (cpp_reader *pfile, cpp_macro *macro)
            return true;
 
          /* Fall through to pick up the error.  */
+         CPP_FALLTHRU ();
        case CPP_COMMA:
          if (!prev_ident)
            {
@@ -2937,6 +2938,7 @@ parse_params (cpp_reader *pfile, cpp_macro *macro)
          if (token->type == CPP_CLOSE_PAREN)
            return true;
          /* Fall through.  */
+         CPP_FALLTHRU ();
 
        case CPP_EOF:
          cpp_error (pfile, CPP_DL_ERROR, "missing ')' in macro parameter 
list");
diff --git gcc/libcpp/pch.c gcc/libcpp/pch.c
index aa5ed6b..31f8bc5 100644
--- gcc/libcpp/pch.c
+++ gcc/libcpp/pch.c
@@ -55,6 +55,7 @@ write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void 
*file_p)
     case NT_VOID:
       if (! (hn->flags & NODE_POISONED))
        return 1;
+      CPP_FALLTHRU ();
 
     case NT_MACRO:
       if ((hn->flags & NODE_BUILTIN)
@@ -231,6 +232,7 @@ count_defs (cpp_reader *pfile ATTRIBUTE_UNUSED, 
cpp_hashnode *hn, void *ss_p)
        return 1;
 
       /* else fall through.  */
+      CPP_FALLTHRU ();
 
     case NT_VOID:
       {
@@ -270,6 +272,7 @@ write_defs (cpp_reader *pfile ATTRIBUTE_UNUSED, 
cpp_hashnode *hn, void *ss_p)
        return 1;
 
       /* else fall through.  */
+      CPP_FALLTHRU ();
 
     case NT_VOID:
       {

Reply via email to