Skip to content

Commit 5caaf40

Browse files
committed
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
1 parent 8a86fe1 commit 5caaf40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+268
-155
lines changed

Zend/Optimizer/block_pass.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
399399
Tsource[VAR_NUM(opline->op1.var)] = NULL;
400400
break;
401401
}
402-
/* break missing intentionally */
402+
ZEND_FALLTHROUGH;
403403

404404
case ZEND_IS_EQUAL:
405405
case ZEND_IS_NOT_EQUAL:
@@ -1037,7 +1037,7 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op
10371037
break;
10381038
case ZEND_JMPZNZ:
10391039
opline->extended_value = ZEND_OPLINE_TO_OFFSET(opline, new_opcodes + blocks[b->successors[1]].start);
1040-
/* break missing intentionally */
1040+
ZEND_FALLTHROUGH;
10411041
case ZEND_JMPZ:
10421042
case ZEND_JMPNZ:
10431043
case ZEND_JMPZ_EX:

Zend/Optimizer/compact_literals.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
466466
map[i] = l_empty_arr;
467467
break;
468468
}
469-
/* break missing intentionally */
469+
ZEND_FALLTHROUGH;
470470
default:
471471
/* don't merge other types */
472472
map[i] = j;

Zend/Optimizer/dce.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ static inline bool is_free_of_live_var(context *ctx, zend_op *opline, zend_ssa_o
385385
if (!(ctx->ssa->var_info[ssa_op->op1_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) {
386386
return 0;
387387
}
388-
/* break missing intentionally */
388+
ZEND_FALLTHROUGH;
389389
case ZEND_FE_FREE:
390390
return !is_var_dead(ctx, ssa_op->op1_use);
391391
default:

Zend/Optimizer/dfa_pass.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ static void zend_ssa_replace_control_link(zend_op_array *op_array, zend_ssa *ssa
613613
if (ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value) == old->start) {
614614
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, dst->start);
615615
}
616-
/* break missing intentionally */
616+
ZEND_FALLTHROUGH;
617617
case ZEND_JMPZ:
618618
case ZEND_JMPNZ:
619619
case ZEND_JMPZ_EX:

Zend/Optimizer/optimize_func_calls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void zend_delete_call_instructions(zend_op *opline)
5959
MAKE_NOP(opline);
6060
return;
6161
}
62-
/* break missing intentionally */
62+
ZEND_FALLTHROUGH;
6363
case ZEND_NEW:
6464
case ZEND_INIT_DYNAMIC_CALL:
6565
case ZEND_INIT_USER_CALL:
@@ -178,7 +178,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx)
178178
ctx->script, op_array, opline, &call_stack[call].is_prototype);
179179
call_stack[call].try_inline =
180180
!call_stack[call].is_prototype && opline->opcode != ZEND_NEW;
181-
/* break missing intentionally */
181+
ZEND_FALLTHROUGH;
182182
case ZEND_INIT_DYNAMIC_CALL:
183183
case ZEND_INIT_USER_CALL:
184184
call_stack[call].opline = opline;

Zend/Optimizer/sccp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ static inline int ct_eval_assign_dim(zval *result, zval *value, zval *key) {
592592
case IS_NULL:
593593
case IS_FALSE:
594594
array_init(result);
595-
/* break missing intentionally */
595+
ZEND_FALLTHROUGH;
596596
case IS_ARRAY:
597597
case PARTIAL_ARRAY:
598598
return ct_eval_add_array_elem(result, value, key);
@@ -695,7 +695,7 @@ static inline int ct_eval_assign_obj(zval *result, zval *value, zval *key) {
695695
case IS_NULL:
696696
case IS_FALSE:
697697
empty_partial_object(result);
698-
/* break missing intentionally */
698+
ZEND_FALLTHROUGH;
699699
case PARTIAL_OBJECT:
700700
return ct_eval_add_obj_prop(result, value, key);
701701
default:

Zend/Optimizer/zend_cfg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ ZEND_API int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, u
314314
break;
315315
case ZEND_INCLUDE_OR_EVAL:
316316
flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS;
317+
ZEND_FALLTHROUGH;
317318
case ZEND_GENERATOR_CREATE:
318319
case ZEND_YIELD:
319320
case ZEND_YIELD_FROM:

Zend/Optimizer/zend_dfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static zend_always_inline void _zend_dfg_add_use_def_op(const zend_op_array *op_
195195
if (!zend_bitset_in(def, var_num)) {
196196
zend_bitset_incl(use, var_num);
197197
}
198-
/* break missing intentionally */
198+
ZEND_FALLTHROUGH;
199199
case ZEND_INIT_ARRAY:
200200
if (((build_flags & ZEND_SSA_RC_INFERENCE)
201201
|| (opline->extended_value & ZEND_ARRAY_ELEMENT_REF))

Zend/Optimizer/zend_inference.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4474,7 +4474,7 @@ ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op,
44744474
/* Division by zero */
44754475
return 1;
44764476
}
4477-
/* break missing intentionally */
4477+
ZEND_FALLTHROUGH;
44784478
case ZEND_SUB:
44794479
case ZEND_MUL:
44804480
case ZEND_POW:
@@ -4574,6 +4574,7 @@ ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op,
45744574
if (t1 & MAY_BE_REF) {
45754575
return 1;
45764576
}
4577+
ZEND_FALLTHROUGH;
45774578
case ZEND_BIND_STATIC:
45784579
case ZEND_UNSET_VAR:
45794580
return (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY));
@@ -4670,6 +4671,9 @@ ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op,
46704671
return 0;
46714672
EMPTY_SWITCH_DEFAULT_CASE()
46724673
}
4674+
/* GCC is getting confused here for the Wimplicit-fallthrough warning with
4675+
* EMPTY_SWITCH_DEFAULT_CASE() macro */
4676+
return 0;
46734677
case ZEND_ARRAY_KEY_EXISTS:
46744678
if ((t2 & MAY_BE_ANY) != MAY_BE_ARRAY) {
46754679
return 1;

Zend/Optimizer/zend_optimizer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ int zend_optimizer_update_op1_const(zend_op_array *op_array,
325325
if (opline->opcode == ZEND_CONCAT && opline->op2_type == IS_CONST) {
326326
opline->opcode = ZEND_FAST_CONCAT;
327327
}
328-
/* break missing intentionally */
328+
ZEND_FALLTHROUGH;
329329
default:
330330
opline->op1.constant = zend_optimizer_add_literal(op_array, val);
331331
break;
@@ -353,7 +353,7 @@ int zend_optimizer_update_op2_const(zend_op_array *op_array,
353353
(opline + 1)->op2.var == opline->result.var) {
354354
return 0;
355355
}
356-
/* break missing intentionally */
356+
ZEND_FALLTHROUGH;
357357
case ZEND_INSTANCEOF:
358358
REQUIRES_STRING(val);
359359
drop_leading_backslash(val);
@@ -507,7 +507,7 @@ int zend_optimizer_update_op2_const(zend_op_array *op_array,
507507
if (opline->opcode == ZEND_CONCAT && opline->op1_type == IS_CONST) {
508508
opline->opcode = ZEND_FAST_CONCAT;
509509
}
510-
/* break missing intentionally */
510+
ZEND_FALLTHROUGH;
511511
default:
512512
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
513513
break;
@@ -674,7 +674,7 @@ void zend_optimizer_migrate_jump(zend_op_array *op_array, zend_op *new_opline, z
674674
break;
675675
case ZEND_JMPZNZ:
676676
new_opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, new_opline, ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value));
677-
/* break missing intentionally */
677+
ZEND_FALLTHROUGH;
678678
case ZEND_JMPZ:
679679
case ZEND_JMPNZ:
680680
case ZEND_JMPZ_EX:
@@ -720,7 +720,7 @@ void zend_optimizer_shift_jump(zend_op_array *op_array, zend_op *opline, uint32_
720720
break;
721721
case ZEND_JMPZNZ:
722722
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value) - shiftlist[ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value)]);
723-
/* break missing intentionally */
723+
ZEND_FALLTHROUGH;
724724
case ZEND_JMPZ:
725725
case ZEND_JMPNZ:
726726
case ZEND_JMPZ_EX:

0 commit comments

Comments
 (0)