Bram, gcc 7.2 enables -Wimplicit-fallthrough It emits a couple of warnings when using this. So add a couple of more /* FALLTHROUGH */ comments and use /* FALLTHRU */ consistently accross the codesbase.
Note also, that the comment must come last before the next case statement, even after #ifdefs (so in 1 or 2 cases, I had to move the comments after a #ifdef statement). This blog article has some more details: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/ Christian -- Als Passwort nahm er seinen Namen, bis eines Nachts die Hacker kamen. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
From d1a2b96a89b440cb36cac24209bfff6bcc66d0cc Mon Sep 17 00:00:00 2001 From: Christian Brabandt <[email protected]> Date: Tue, 24 Oct 2017 14:38:35 +0200 Subject: [PATCH] Fix fallthrough comments gcc 7.2 enables -Wimplicit-fallthrough and compiling Vim with gcc gives a couple of fallthrough warnings. Also fix the style to always have a space between the comment leader and the word. Additionally, add a couple of new /* FALLTHROUGH */ comments in a few places that have been warned about. Note: the fallthrough comment must be last before the next case statement, so it needs to come **after** the #ifdef statements. --- src/buffer.c | 2 ++ src/edit.c | 5 ++++- src/eval.c | 4 ++-- src/ex_docmd.c | 2 +- src/ex_getln.c | 3 +-- src/main.c | 4 ++-- src/message.c | 2 +- src/normal.c | 9 +++++---- src/regexp.c | 12 ++++++------ src/regexp_nfa.c | 3 ++- src/spell.c | 12 ++++++------ src/window.c | 4 ++-- 12 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 1bf692a83..0d69b9d66 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -4325,6 +4325,7 @@ build_stl_str_hl( case STL_OFFSET_X: base = 'X'; + /* FALLTHROUGH */ case STL_OFFSET: #ifdef FEAT_BYTEOFF l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL); @@ -4336,6 +4337,7 @@ build_stl_str_hl( case STL_BYTEVAL_X: base = 'X'; + /* FALLTHROUGH */ case STL_BYTEVAL: num = byteval; if (num == NL) diff --git a/src/edit.c b/src/edit.c index 5f513068a..a17962052 100644 --- a/src/edit.c +++ b/src/edit.c @@ -984,7 +984,7 @@ edit( case ESC: /* End input mode */ if (echeck_abbr(ESC + ABBR_OFF)) break; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case Ctrl_C: /* End input mode */ #ifdef FEAT_CMDWIN @@ -5774,13 +5774,16 @@ quote_meta(char_u *dest, char_u *src, int len) if (ctrl_x_mode == CTRL_X_DICTIONARY || ctrl_x_mode == CTRL_X_THESAURUS) break; + /* FALLTHROUGH */ case '~': if (!p_magic) /* quote these only if magic is set */ break; + /* FALLTHROUGH */ case '\\': if (ctrl_x_mode == CTRL_X_DICTIONARY || ctrl_x_mode == CTRL_X_THESAURUS) break; + /* FALLTHROUGH */ case '^': /* currently it's not needed. */ case '$': m++; diff --git a/src/eval.c b/src/eval.c index d4fba7fe0..8cb91e783 100644 --- a/src/eval.c +++ b/src/eval.c @@ -6995,7 +6995,7 @@ free_tv(typval_T *varp) { case VAR_FUNC: func_unref(varp->vval.v_string); - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case VAR_STRING: vim_free(varp->vval.v_string); break; @@ -7040,7 +7040,7 @@ clear_tv(typval_T *varp) { case VAR_FUNC: func_unref(varp->vval.v_string); - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case VAR_STRING: vim_free(varp->vval.v_string); varp->vval.v_string = NULL; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 6564ad9ba..59a7d418e 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -4115,7 +4115,7 @@ set_one_cmd_context( case CMD_bunload: while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) arg = xp->xp_pattern + 1; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case CMD_buffer: case CMD_sbuffer: case CMD_checktime: diff --git a/src/ex_getln.c b/src/ex_getln.c index 6876a215a..ba6a40359 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -1563,9 +1563,8 @@ getcmdline( break; goto cmdline_not_changed; } - /* FALLTHROUGH */ - #ifdef FEAT_CMDHIST + /* FALLTHROUGH */ case K_UP: case K_DOWN: case K_S_UP: diff --git a/src/main.c b/src/main.c index 3db8efb9b..0dad4d6a8 100644 --- a/src/main.c +++ b/src/main.c @@ -2228,7 +2228,7 @@ command_line_scan(mparm_T *parmp) argv_idx = -1; break; } - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case 'S': /* "-S {file}" execute Vim script */ case 'i': /* "-i {viminfo}" use for viminfo */ #ifndef FEAT_DIFF @@ -2386,7 +2386,7 @@ scripterror: argv_idx = -1; break; } - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case 'W': /* "-W {scriptout}" overwrite script file */ if (scriptout != NULL) goto scripterror; diff --git a/src/message.c b/src/message.c index af2260759..11336af48 100644 --- a/src/message.c +++ b/src/message.c @@ -2837,7 +2837,7 @@ do_more_prompt(int typed_char) skip_redraw = TRUE; /* skip redraw once */ need_wait_return = FALSE; /* don't wait in main() */ } - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case 'q': /* quit */ case Ctrl_C: case ESC: diff --git a/src/normal.c b/src/normal.c index fbeffe51e..e781cd70e 100644 --- a/src/normal.c +++ b/src/normal.c @@ -1945,6 +1945,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) AppendToRedobuff((char_u *)"!\r"); /* use any last used !cmd */ else bangredo = TRUE; /* do_bang() will put cmd in redo buffer */ + /* FALLTHROUGH */ case OP_INDENT: case OP_COLON: @@ -5150,7 +5151,7 @@ dozet: break; } undo = TRUE; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case 'g': /* "zg": add good word to word list */ case 'w': /* "zw": add wrong word to word list */ @@ -8267,7 +8268,7 @@ nv_g_cmd(cmdarg_T *cap) /* "g'm" and "g`m": jump to mark without setting pcmark */ case '\'': cap->arg = TRUE; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case '`': nv_gomark(cap); break; @@ -8328,7 +8329,7 @@ nv_g_cmd(cmdarg_T *cap) case 'q': case 'w': oap->cursor_start = curwin->w_cursor; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case '~': case 'u': case 'U': @@ -9117,7 +9118,7 @@ nv_edit(cmdarg_T *cap) * the first column, then it inserts. */ if (curwin->w_cursor.col == 0) break; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case 'a': /* "a"ppend is like "i"nsert on the next character. */ #ifdef FEAT_VIRTUALEDIT diff --git a/src/regexp.c b/src/regexp.c index 147a605ba..699a0bf9c 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -1997,7 +1997,7 @@ regatom(int *flagp) goto collection; /* "\_x" is character class plus newline */ - /*FALLTHROUGH*/ + /* FALLTHROUGH */ /* * Character classes. @@ -5847,7 +5847,7 @@ regrepeat( case IDENT: case IDENT + ADD_NL: testval = TRUE; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case SIDENT: case SIDENT + ADD_NL: while (count < maxcount) @@ -5877,7 +5877,7 @@ regrepeat( case KWORD: case KWORD + ADD_NL: testval = TRUE; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case SKWORD: case SKWORD + ADD_NL: while (count < maxcount) @@ -5908,7 +5908,7 @@ regrepeat( case FNAME: case FNAME + ADD_NL: testval = TRUE; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case SFNAME: case SFNAME + ADD_NL: while (count < maxcount) @@ -5938,7 +5938,7 @@ regrepeat( case PRINT: case PRINT + ADD_NL: testval = TRUE; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case SPRINT: case SPRINT + ADD_NL: while (count < maxcount) @@ -6131,7 +6131,7 @@ do_class: case ANYOF: case ANYOF + ADD_NL: testval = TRUE; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case ANYBUT: case ANYBUT + ADD_NL: diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 90ae319af..70b49a0c6 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -1321,7 +1321,7 @@ nfa_regatom(void) goto collection; /* "\_x" is character class plus newline */ - /*FALLTHROUGH*/ + /* FALLTHROUGH */ /* * Character classes. @@ -4699,6 +4699,7 @@ skip_add: subs = addstate(l, state->out, subs, pim, off_arg); break; } + /* FALLTHROUGH */ case NFA_MCLOSE1: case NFA_MCLOSE2: case NFA_MCLOSE3: diff --git a/src/spell.c b/src/spell.c index eb1b9fb6c..cdcf82295 100644 --- a/src/spell.c +++ b/src/spell.c @@ -5019,7 +5019,7 @@ suggest_trie_walk( } PROF_STORE(sp->ts_state) sp->ts_state = STATE_PLAIN; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case STATE_PLAIN: /* @@ -5243,7 +5243,7 @@ suggest_trie_walk( } break; } - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case STATE_INS_PREP: if (sp->ts_flags & TSF_DIDDEL) @@ -5277,7 +5277,7 @@ suggest_trie_walk( } break; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case STATE_INS: /* Insert one byte. Repeat this for each possible byte at this @@ -5464,7 +5464,7 @@ suggest_trie_walk( *p = p[1]; p[1] = c; } - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case STATE_SWAP3: /* Swap two bytes, skipping one: "123" -> "321". We change @@ -5703,7 +5703,7 @@ suggest_trie_walk( p[1] = p[2]; p[2] = c; } - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case STATE_REP_INI: /* Check if matching with REP items from the .aff file would work. @@ -5736,7 +5736,7 @@ suggest_trie_walk( PROF_STORE(sp->ts_state) sp->ts_state = STATE_REP; - /*FALLTHROUGH*/ + /* FALLTHROUGH */ case STATE_REP: /* Try matching with REP items from the .aff file. For each match diff --git a/src/window.c b/src/window.c index 96e32d8ef..ad084a4eb 100644 --- a/src/window.c +++ b/src/window.c @@ -433,8 +433,8 @@ newwindow: g_do_tagpreview = Prenum; else g_do_tagpreview = p_pvh; - /*FALLTHROUGH*/ #endif + /* FALLTHROUGH */ case ']': case Ctrl_RSB: CHECK_CMDWIN @@ -557,8 +557,8 @@ wingotofile: g_do_tagpreview = Prenum; else g_do_tagpreview = p_pvh; - /*FALLTHROUGH*/ #endif + /* FALLTHROUGH */ case ']': case Ctrl_RSB: /* keep Visual mode, can select words to use as a tag */ -- 2.14.1
