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:

Zend/Optimizer/zend_ssa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
713713
break;
714714
case ZEND_ADD_ARRAY_ELEMENT:
715715
ssa_ops[k].result_use = var[EX_VAR_TO_NUM(opline->result.var)];
716-
/* break missing intentionally */
716+
ZEND_FALLTHROUGH;
717717
case ZEND_INIT_ARRAY:
718718
if (((build_flags & ZEND_SSA_RC_INFERENCE)
719719
|| (opline->extended_value & ZEND_ARRAY_ELEMENT_REF))

Zend/zend_API.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec
942942
case 'Z': /* replace with 'z' */
943943
case 'L': /* replace with 'l' */
944944
ZEND_ASSERT(0 && "ZPP modifier no longer supported");
945+
ZEND_FALLTHROUGH;
945946
default:
946947
return "unknown";
947948
}

Zend/zend_ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
20492049
break;
20502050
case ZEND_AST_PROP_ELEM:
20512051
smart_str_appendc(str, '$');
2052-
/* break missing intentionally */
2052+
ZEND_FALLTHROUGH;
20532053
case ZEND_AST_CONST_ELEM:
20542054
zend_ast_export_name(str, ast->child[0], 0, indent);
20552055
APPEND_DEFAULT_VALUE(1);

Zend/zend_builtin_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ ZEND_FUNCTION(define)
525525
val = &val_free;
526526
break;
527527
}
528-
/* no break */
528+
ZEND_FALLTHROUGH;
529529
default:
530530
zval_ptr_dtor(&val_free);
531531
zend_argument_type_error(2, "cannot be an object, %s given", zend_zval_type_name(val));

Zend/zend_execute.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static zend_never_inline ZEND_COLD zval *_get_zval_cv_lookup(zval *ptr, uint32_t
298298
break;
299299
case BP_VAR_RW:
300300
zval_undefined_cv(var EXECUTE_DATA_CC);
301-
/* break missing intentionally */
301+
ZEND_FALLTHROUGH;
302302
case BP_VAR_W:
303303
ZVAL_NULL(ptr);
304304
break;
@@ -1418,6 +1418,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type
14181418
}
14191419
case IS_UNDEF:
14201420
ZVAL_UNDEFINED_OP2();
1421+
ZEND_FALLTHROUGH;
14211422
case IS_DOUBLE:
14221423
case IS_NULL:
14231424
case IS_FALSE:
@@ -2081,7 +2082,7 @@ static zend_never_inline zend_uchar slow_index_convert(HashTable *ht, const zval
20812082
if (EG(exception)) {
20822083
return IS_NULL;
20832084
}
2084-
/* break missing intentionally */
2085+
ZEND_FALLTHROUGH;
20852086
}
20862087
case IS_NULL:
20872088
value->str = ZSTR_EMPTY_ALLOC();
@@ -2122,7 +2123,7 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
21222123
switch (type) {
21232124
case BP_VAR_R:
21242125
zend_undefined_offset(hval);
2125-
/* break missing intentionally */
2126+
ZEND_FALLTHROUGH;
21262127
case BP_VAR_UNSET:
21272128
case BP_VAR_IS:
21282129
retval = &EG(uninitialized_zval);
@@ -2151,7 +2152,7 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
21512152
switch (type) {
21522153
case BP_VAR_R:
21532154
zend_undefined_index(offset_key);
2154-
/* break missing intentionally */
2155+
ZEND_FALLTHROUGH;
21552156
case BP_VAR_UNSET:
21562157
case BP_VAR_IS:
21572158
retval = &EG(uninitialized_zval);
@@ -2389,6 +2390,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
23892390
}
23902391
case IS_UNDEF:
23912392
ZVAL_UNDEFINED_OP2();
2393+
ZEND_FALLTHROUGH;
23922394
case IS_DOUBLE:
23932395
case IS_NULL:
23942396
case IS_FALSE:

Zend/zend_highlight.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ ZEND_API void zend_strip(void)
184184
zend_write(" ", sizeof(" ") - 1);
185185
prev_space = 1;
186186
}
187-
/* lack of break; is intentional */
187+
ZEND_FALLTHROUGH;
188188
case T_COMMENT:
189189
case T_DOC_COMMENT:
190190
ZVAL_UNDEF(&token);

Zend/zend_ini_scanner.l

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static void zend_ini_copy_typed_value(zval *retval, const int type, const char *
187187
if (convert_to_number(retval, str, len) == SUCCESS) {
188188
break;
189189
}
190-
/* intentional fall-through */
190+
ZEND_FALLTHROUGH;
191191
default:
192192
zend_ini_copy_value(retval, str, len);
193193
}
@@ -328,6 +328,7 @@ static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_ty
328328
*t++ = *s;
329329
break;
330330
}
331+
ZEND_FALLTHROUGH;
331332
case '\\':
332333
case '$':
333334
*t++ = *s;
@@ -606,7 +607,7 @@ end_raw_value_chars:
606607
if (YYCURSOR < YYLIMIT && *YYCURSOR != '"') {
607608
YYCURSOR++;
608609
}
609-
/* fall through */
610+
ZEND_FALLTHROUGH;
610611
default:
611612
continue;
612613
}

Zend/zend_language_scanner.l

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ static zend_result zend_scan_escape_string(zval *zendlval, char *str, int len, c
986986
*t++ = *s;
987987
break;
988988
}
989+
ZEND_FALLTHROUGH;
989990
case '\\':
990991
case '$':
991992
*t++ = *s;
@@ -2373,7 +2374,7 @@ inline_char_handler:
23732374
YYCURSOR--;
23742375
break;
23752376
}
2376-
/* fall through */
2377+
ZEND_FALLTHROUGH;
23772378
default:
23782379
continue;
23792380
}
@@ -2556,7 +2557,7 @@ skip_escape_conversion:
25562557
if (YYCURSOR < YYLIMIT) {
25572558
YYCURSOR++;
25582559
}
2559-
/* fall through */
2560+
ZEND_FALLTHROUGH;
25602561
default:
25612562
continue;
25622563
}
@@ -2793,7 +2794,7 @@ skip_escape_conversion:
27932794
if (YYCURSOR < YYLIMIT) {
27942795
YYCURSOR++;
27952796
}
2796-
/* fall through */
2797+
ZEND_FALLTHROUGH;
27972798
default:
27982799
continue;
27992800
}
@@ -2840,7 +2841,7 @@ double_quotes_scan_done:
28402841
if (YYCURSOR < YYLIMIT) {
28412842
YYCURSOR++;
28422843
}
2843-
/* fall through */
2844+
ZEND_FALLTHROUGH;
28442845
default:
28452846
continue;
28462847
}
@@ -2876,7 +2877,7 @@ double_quotes_scan_done:
28762877
if (*YYCURSOR == '\n') {
28772878
YYCURSOR++;
28782879
}
2879-
/* fall through */
2880+
ZEND_FALLTHROUGH;
28802881
case '\n':
28812882
indentation = spacing = 0;
28822883
@@ -2946,7 +2947,7 @@ double_quotes_scan_done:
29462947
if (YYCURSOR < YYLIMIT && *YYCURSOR != '\n' && *YYCURSOR != '\r') {
29472948
YYCURSOR++;
29482949
}
2949-
/* fall through */
2950+
ZEND_FALLTHROUGH;
29502951
default:
29512952
continue;
29522953
}
@@ -3000,7 +3001,7 @@ heredoc_scan_done:
30003001
if (*YYCURSOR == '\n') {
30013002
YYCURSOR++;
30023003
}
3003-
/* fall through */
3004+
ZEND_FALLTHROUGH;
30043005
case '\n':
30053006
indentation = spacing = 0;
30063007
@@ -3051,7 +3052,7 @@ heredoc_scan_done:
30513052
30523053
goto nowdoc_scan_done;
30533054
}
3054-
/* fall through */
3055+
ZEND_FALLTHROUGH;
30553056
default:
30563057
continue;
30573058
}

Zend/zend_object_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,7 @@ ZEND_API HashTable *zend_std_get_properties_for(zend_object *obj, zend_prop_purp
18121812
}
18131813
return ht;
18141814
}
1815-
/* break missing intentionally */
1815+
ZEND_FALLTHROUGH;
18161816
case ZEND_PROP_PURPOSE_ARRAY_CAST:
18171817
case ZEND_PROP_PURPOSE_SERIALIZE:
18181818
case ZEND_PROP_PURPOSE_VAR_EXPORT:

0 commit comments

Comments
 (0)