Skip to content

Commit

Permalink
cleanup: silence fallthrough warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Blub committed Jul 23, 2017
1 parent 163c4b9 commit 5a0d645
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1392,8 +1392,8 @@ ast_expression *fold::op(const oper_info *info, ast_expression **opexprs) {
return nullptr;

switch(info->operands) {
case 3: if(!c) return nullptr;
case 2: if(!b) return nullptr;
case 3: if(!c) return nullptr; [[fallthrough]];
case 2: if(!b) return nullptr; [[fallthrough]];
case 1:
if(!a) {
compile_error(ctx(), "internal error: fold_op no operands to fold\n");
Expand Down Expand Up @@ -1560,6 +1560,7 @@ ast_expression *fold::superfluous(ast_expression *left, ast_expression *right, i
case INSTR_DIV_F:
if (swapped)
return nullptr;
[[fallthrough]];
case INSTR_MUL_F:
if (immvalue_float(load) == 1.0f) {
++opts_optimizationcount[OPTIM_PEEPHOLE];
Expand All @@ -1572,6 +1573,7 @@ ast_expression *fold::superfluous(ast_expression *left, ast_expression *right, i
case INSTR_SUB_F:
if (swapped)
return nullptr;
[[fallthrough]];
case INSTR_ADD_F:
if (immvalue_float(load) == 0.0f) {
++opts_optimizationcount[OPTIM_PEEPHOLE];
Expand All @@ -1591,6 +1593,7 @@ ast_expression *fold::superfluous(ast_expression *left, ast_expression *right, i
case INSTR_SUB_V:
if (swapped)
return nullptr;
[[fallthrough]];
case INSTR_ADD_V:
if (vec3_cmp(immvalue_vector(load), vec3_create(0, 0, 0))) {
++opts_optimizationcount[OPTIM_PEEPHOLE];
Expand Down
4 changes: 4 additions & 0 deletions parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)

case opid2('|','|'):
generated_op += 1; /* INSTR_OR */
[[fallthrough]];
case opid2('&','&'):
generated_op += INSTR_AND;
if (!(out = parser->m_fold.op(op, exprs))) {
Expand Down Expand Up @@ -857,10 +858,13 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)

case opid1('>'):
generated_op += 1; /* INSTR_GT */
[[fallthrough]];
case opid1('<'):
generated_op += 1; /* INSTR_LT */
[[fallthrough]];
case opid2('>', '='):
generated_op += 1; /* INSTR_GE */
[[fallthrough]];
case opid2('<', '='):
generated_op += INSTR_LE;
if (NotSameType(TYPE_FLOAT)) {
Expand Down

0 comments on commit 5a0d645

Please sign in to comment.