From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 023845764A9; Wed, 9 Aug 2023 18:46:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 023845764A9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1691595989; bh=kvJWhv2tZjoq5yh5yQMLodwH5ma0vcxzVLogIcXtUso=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=dWjSHGKlCqR8Lnav2DZfG21fZm6SP0zjvFNfMMV2EJ9j5P5kV/IykyPcoXOgcVT0v o3y7De85xDyccM3Jntej9gBa+gqv2OyoR622HKyJptOyzFX5xEiYjQIg7A0Eb+LhoY 5qGi/gwQ6bwKmwhx9HnwjDjPKe4eCkXti0cdcbdY= Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [95.163.41.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A917F576495 for ; Wed, 9 Aug 2023 18:41:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A917F576495 Received: by smtp32.i.mail.ru with esmtpa (envelope-from ) id 1qTlJ7-003Nbf-2z; Wed, 09 Aug 2023 18:41:10 +0300 To: Igor Munkin , Sergey Bronnikov Date: Wed, 9 Aug 2023 18:36:00 +0300 Message-ID: <4a61aa2abda31b52418bdfee2890be727e4738a4.1691592488.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD969E04B5EED670DC804E38A5F9341E5D89B81E0241E25E490182A05F538085040CD64BDFC66706D976A27CB2E765B16166282E013C0337ADC218A9EE735F31965 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7BF6CFCE92D77DF21EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637FBDDB35DE4C816078638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8E9DEECA8D5079A16529AE1422AC62606117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC7F48962964D238D0A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18BDFBBEFFF4125B51D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4B7C6FCE95544A9834D8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE360910C30DCD593B16E0066C2D8992A16C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637BBEA499411984DA1EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A584F5DE24649C3D6B2F6BEBBAB7CE8134023B1F181720444CF87CCE6106E1FC07E67D4AC08A07B9B0735DFC8FA7AC12079C5DF10A05D560A950611B66E3DA6D700B0A020F03D25A0997E3FB2386030E77 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF929A8DFF75950FE38F0119787F4D1FBA1BF84A51DAF66FB15CE84A9043000B758657CCA151A12AF51529AA6C8ABD04CA1C1DAAFC4532248DB74106406F49F7FEA74DFFEFA5DC0E7F02C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojUzxoxvtYX2oWVG2CJ2Mang== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A76964C5C56EDF8B84FB6A27CB2E765B16161442BDFAA4939184DEDBA653FF35249392D99EB8CC7091A70E183A470755BFD208F19895AA18418972D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit 11/19] Fix GCC 7 -Wimplicit-fallthrough warnings. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Mike Pall (cherry-picked from commit d4ee80342770d1281e2ce877f8ae8ab1d99e6528) This patch adds the `/* fallthrough */` where it may trigger the `-Wimplicit-fallthrough` [1] warning. Some cases still not covered by this comment and will be fixed in the future commits. [1]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wimplicit-fallthrough Sergey Kaplun: * added the description for the commit Part of tarantool/tarantool#8825 --- dynasm/dasm_arm.h | 2 ++ dynasm/dasm_mips.h | 1 + dynasm/dasm_ppc.h | 1 + dynasm/dasm_x86.h | 18 ++++++++++++++---- src/lj_asm.c | 7 ++++++- src/lj_cparse.c | 10 ++++++++++ src/lj_err.c | 1 + src/lj_opt_sink.c | 2 +- src/lj_parse.c | 3 ++- src/luajit.c | 1 + 10 files changed, 39 insertions(+), 7 deletions(-) diff --git a/dynasm/dasm_arm.h b/dynasm/dasm_arm.h index a43f7c66..1d404ccd 100644 --- a/dynasm/dasm_arm.h +++ b/dynasm/dasm_arm.h @@ -254,6 +254,7 @@ void dasm_put(Dst_DECL, int start, ...) case DASM_IMMV8: CK((n & 3) == 0, RANGE_I); n >>= 2; + /* fallthrough */ case DASM_IMML8: case DASM_IMML12: CK(n >= 0 ? ((n>>((ins>>5)&31)) == 0) : @@ -371,6 +372,7 @@ int dasm_encode(Dst_DECL, void *buffer) break; case DASM_REL_LG: CK(n >= 0, UNDEF_LG); + /* fallthrough */ case DASM_REL_PC: CK(n >= 0, UNDEF_PC); n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base) - 4; diff --git a/dynasm/dasm_mips.h b/dynasm/dasm_mips.h index 4b49fd8c..71a835b2 100644 --- a/dynasm/dasm_mips.h +++ b/dynasm/dasm_mips.h @@ -350,6 +350,7 @@ int dasm_encode(Dst_DECL, void *buffer) break; case DASM_REL_LG: CK(n >= 0, UNDEF_LG); + /* fallthrough */ case DASM_REL_PC: CK(n >= 0, UNDEF_PC); n = *DASM_POS2PTR(D, n); diff --git a/dynasm/dasm_ppc.h b/dynasm/dasm_ppc.h index 3a7ee9b0..83fc030a 100644 --- a/dynasm/dasm_ppc.h +++ b/dynasm/dasm_ppc.h @@ -354,6 +354,7 @@ int dasm_encode(Dst_DECL, void *buffer) break; case DASM_REL_LG: CK(n >= 0, UNDEF_LG); + /* fallthrough */ case DASM_REL_PC: CK(n >= 0, UNDEF_PC); n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base); diff --git a/dynasm/dasm_x86.h b/dynasm/dasm_x86.h index bc636357..2a276042 100644 --- a/dynasm/dasm_x86.h +++ b/dynasm/dasm_x86.h @@ -194,12 +194,13 @@ void dasm_put(Dst_DECL, int start, ...) switch (action) { case DASM_DISP: if (n == 0) { if (mrm < 0) mrm = p[-2]; if ((mrm&7) != 5) break; } - case DASM_IMM_DB: if (((n+128)&-256) == 0) goto ob; + /* fallthrough */ + case DASM_IMM_DB: if (((n+128)&-256) == 0) goto ob; /* fallthrough */ case DASM_REL_A: /* Assumes ptrdiff_t is int. !x64 */ case DASM_IMM_D: ofs += 4; break; case DASM_IMM_S: CK(((n+128)&-256) == 0, RANGE_I); goto ob; case DASM_IMM_B: CK((n&-256) == 0, RANGE_I); ob: ofs++; break; - case DASM_IMM_WB: if (((n+128)&-256) == 0) goto ob; + case DASM_IMM_WB: if (((n+128)&-256) == 0) goto ob; /* fallthrough */ case DASM_IMM_W: CK((n&-65536) == 0, RANGE_I); ofs += 2; break; case DASM_SPACE: p++; ofs += n; break; case DASM_SETLABEL: b[pos-2] = -0x40000000; break; /* Neg. label ofs. */ @@ -207,8 +208,8 @@ void dasm_put(Dst_DECL, int start, ...) if (*p < 0x40 && p[1] == DASM_DISP) mrm = n; if (*p < 0x20 && (n&7) == 4) ofs++; switch ((*p++ >> 3) & 3) { - case 3: n |= b[pos-3]; - case 2: n |= b[pos-2]; + case 3: n |= b[pos-3]; /* fallthrough */ + case 2: n |= b[pos-2]; /* fallthrough */ case 1: if (n <= 7) { b[pos-1] |= 0x10; ofs--; } } continue; @@ -329,11 +330,14 @@ int dasm_link(Dst_DECL, size_t *szp) pos += 2; break; } + /* fallthrough */ case DASM_SPACE: case DASM_IMM_LG: case DASM_VREG: p++; + /* fallthrough */ case DASM_DISP: case DASM_IMM_S: case DASM_IMM_B: case DASM_IMM_W: case DASM_IMM_D: case DASM_IMM_WB: case DASM_IMM_DB: case DASM_SETLABEL: case DASM_REL_A: case DASM_IMM_PC: pos++; break; case DASM_LABEL_LG: p++; + /* fallthrough */ case DASM_LABEL_PC: b[pos++] += ofs; break; /* Fix label offset. */ case DASM_ALIGN: ofs -= (b[pos++]+ofs)&*p++; break; /* Adjust ofs. */ case DASM_EXTERN: p += 2; break; @@ -391,12 +395,15 @@ int dasm_encode(Dst_DECL, void *buffer) if (mrm != 5) { mm[-1] -= 0x80; break; } } if (((n+128) & -256) != 0) goto wd; else mm[-1] -= 0x40; } + /* fallthrough */ case DASM_IMM_S: case DASM_IMM_B: wb: dasmb(n); break; case DASM_IMM_DB: if (((n+128)&-256) == 0) { db: if (!mark) mark = cp; mark[-2] += 2; mark = NULL; goto wb; } else mark = NULL; + /* fallthrough */ case DASM_IMM_D: wd: dasmd(n); break; case DASM_IMM_WB: if (((n+128)&-256) == 0) goto db; else mark = NULL; + /* fallthrough */ case DASM_IMM_W: dasmw(n); break; case DASM_VREG: { int t = *p++; @@ -421,6 +428,7 @@ int dasm_encode(Dst_DECL, void *buffer) } case DASM_REL_LG: p++; if (n >= 0) goto rel_pc; b++; n = (int)(ptrdiff_t)D->globals[-n]; + /* fallthrough */ case DASM_REL_A: rel_a: n -= (int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */ case DASM_REL_PC: rel_pc: { int shrink = *b++; @@ -432,6 +440,7 @@ int dasm_encode(Dst_DECL, void *buffer) } case DASM_IMM_LG: p++; if (n < 0) { n = (int)(ptrdiff_t)D->globals[-n]; goto wd; } + /* fallthrough */ case DASM_IMM_PC: { int *pb = DASM_POS2PTR(D, n); n = *pb < 0 ? pb[1] : (*pb + (int)(ptrdiff_t)base); @@ -452,6 +461,7 @@ int dasm_encode(Dst_DECL, void *buffer) case DASM_EXTERN: n = DASM_EXTERN(Dst, cp, p[1], *p); p += 2; goto wd; case DASM_MARK: mark = cp; break; case DASM_ESC: action = *p++; + /* fallthrough */ default: *cp++ = action; break; case DASM_SECTION: case DASM_STOP: goto stop; } diff --git a/src/lj_asm.c b/src/lj_asm.c index 15de7e33..2d570bb9 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c @@ -2188,9 +2188,12 @@ static void asm_setup_regsp(ASMState *as) if (ir->op2 != REF_NIL && as->evenspill < 4) as->evenspill = 4; /* lj_cdata_newv needs 4 args. */ } + /* fallthrough */ #else + /* fallthrough */ case IR_CNEW: #endif + /* fallthrough */ case IR_TNEW: case IR_TDUP: case IR_CNEWI: case IR_TOSTR: case IR_BUFSTR: ir->prev = REGSP_HINT(RID_RET); @@ -2206,6 +2209,7 @@ static void asm_setup_regsp(ASMState *as) case IR_LDEXP: #endif #endif + /* fallthrough */ case IR_POW: if (!LJ_SOFTFP && irt_isnum(ir->t)) { if (inloop) @@ -2217,7 +2221,7 @@ static void asm_setup_regsp(ASMState *as) continue; #endif } - /* fallthrough for integer POW */ + /* fallthrough */ /* for integer POW */ case IR_DIV: case IR_MOD: if (!irt_isnum(ir->t)) { ir->prev = REGSP_HINT(RID_RET); @@ -2254,6 +2258,7 @@ static void asm_setup_regsp(ASMState *as) case IR_BSHL: case IR_BSHR: case IR_BSAR: if ((as->flags & JIT_F_BMI2)) /* Except if BMI2 is available. */ break; + /* fallthrough */ case IR_BROL: case IR_BROR: if (!irref_isk(ir->op2) && !ra_hashint(IR(ir->op2)->r)) { IR(ir->op2)->r = REGSP_HINT(RID_ECX); diff --git a/src/lj_cparse.c b/src/lj_cparse.c index 07c643d4..cd032b8e 100644 --- a/src/lj_cparse.c +++ b/src/lj_cparse.c @@ -595,28 +595,34 @@ static void cp_expr_infix(CPState *cp, CPValue *k, int pri) k->id = k2.id > k3.id ? k2.id : k3.id; continue; } + /* fallthrough */ case 1: if (cp_opt(cp, CTOK_OROR)) { cp_expr_sub(cp, &k2, 2); k->i32 = k->u32 || k2.u32; k->id = CTID_INT32; continue; } + /* fallthrough */ case 2: if (cp_opt(cp, CTOK_ANDAND)) { cp_expr_sub(cp, &k2, 3); k->i32 = k->u32 && k2.u32; k->id = CTID_INT32; continue; } + /* fallthrough */ case 3: if (cp_opt(cp, '|')) { cp_expr_sub(cp, &k2, 4); k->u32 = k->u32 | k2.u32; goto arith_result; } + /* fallthrough */ case 4: if (cp_opt(cp, '^')) { cp_expr_sub(cp, &k2, 5); k->u32 = k->u32 ^ k2.u32; goto arith_result; } + /* fallthrough */ case 5: if (cp_opt(cp, '&')) { cp_expr_sub(cp, &k2, 6); k->u32 = k->u32 & k2.u32; goto arith_result; } + /* fallthrough */ case 6: if (cp_opt(cp, CTOK_EQ)) { cp_expr_sub(cp, &k2, 7); k->i32 = k->u32 == k2.u32; k->id = CTID_INT32; @@ -625,6 +631,7 @@ static void cp_expr_infix(CPState *cp, CPValue *k, int pri) cp_expr_sub(cp, &k2, 7); k->i32 = k->u32 != k2.u32; k->id = CTID_INT32; continue; } + /* fallthrough */ case 7: if (cp_opt(cp, '<')) { cp_expr_sub(cp, &k2, 8); @@ -659,6 +666,7 @@ static void cp_expr_infix(CPState *cp, CPValue *k, int pri) k->id = CTID_INT32; continue; } + /* fallthrough */ case 8: if (cp_opt(cp, CTOK_SHL)) { cp_expr_sub(cp, &k2, 9); k->u32 = k->u32 << k2.u32; @@ -671,6 +679,7 @@ static void cp_expr_infix(CPState *cp, CPValue *k, int pri) k->u32 = k->u32 >> k2.u32; continue; } + /* fallthrough */ case 9: if (cp_opt(cp, '+')) { cp_expr_sub(cp, &k2, 10); k->u32 = k->u32 + k2.u32; @@ -680,6 +689,7 @@ static void cp_expr_infix(CPState *cp, CPValue *k, int pri) } else if (cp_opt(cp, '-')) { cp_expr_sub(cp, &k2, 10); k->u32 = k->u32 - k2.u32; goto arith_result; } + /* fallthrough */ case 10: if (cp_opt(cp, '*')) { cp_expr_unary(cp, &k2); k->u32 = k->u32 * k2.u32; goto arith_result; diff --git a/src/lj_err.c b/src/lj_err.c index 9903d273..8d7134d9 100644 --- a/src/lj_err.c +++ b/src/lj_err.c @@ -167,6 +167,7 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode) case FRAME_CONT: /* Continuation frame. */ if (frame_iscont_fficb(frame)) goto unwind_c; + /* fallthrough */ case FRAME_VARG: /* Vararg frame. */ frame = frame_prevd(frame); break; diff --git a/src/lj_opt_sink.c b/src/lj_opt_sink.c index a16d112f..c16363e7 100644 --- a/src/lj_opt_sink.c +++ b/src/lj_opt_sink.c @@ -100,8 +100,8 @@ static void sink_mark_ins(jit_State *J) (LJ_32 && ir+1 < irlast && (ir+1)->o == IR_HIOP && !sink_checkphi(J, ir, (ir+1)->op2)))) irt_setmark(ir->t); /* Mark ineligible allocation. */ - /* fallthrough */ #endif + /* fallthrough */ case IR_USTORE: irt_setmark(IR(ir->op2)->t); /* Mark stored value. */ break; diff --git a/src/lj_parse.c b/src/lj_parse.c index 343fa797..e238afa3 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c @@ -2684,7 +2684,8 @@ static int parse_stmt(LexState *ls) lj_lex_next(ls); parse_goto(ls); break; - } /* else: fallthrough */ + } + /* fallthrough */ default: parse_call_assign(ls); break; diff --git a/src/luajit.c b/src/luajit.c index 1ca24301..3a3ec247 100644 --- a/src/luajit.c +++ b/src/luajit.c @@ -421,6 +421,7 @@ static int collectargs(char **argv, int *flags) break; case 'e': *flags |= FLAGS_EXEC; + /* fallthrough */ case 'j': /* LuaJIT extension */ case 'l': *flags |= FLAGS_OPTION; -- 2.41.0