Skip to content

Commit cd7ee44

Browse files
committed
Fix [-Wimplicit-fallthrough] warnings in Zend Engine
1 parent 14eece7 commit cd7ee44

12 files changed

+42
-36
lines changed

Zend/zend_API.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec
884884
case 'Z': /* replace with 'z' */
885885
case 'L': /* replace with 'l' */
886886
ZEND_ASSERT(0 && "ZPP modifier no longer supported");
887+
fallthrough;
887888
default:
888889
return "unknown";
889890
}

Zend/zend_ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
20132013
break;
20142014
case ZEND_AST_PROP_ELEM:
20152015
smart_str_appendc(str, '$');
2016-
/* break missing intentionally */
2016+
fallthrough;
20172017
case ZEND_AST_CONST_ELEM:
20182018
zend_ast_export_name(str, ast->child[0], 0, indent);
20192019
APPEND_DEFAULT_VALUE(1);

Zend/zend_builtin_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ ZEND_FUNCTION(define)
528528
val = &val_free;
529529
break;
530530
}
531-
/* no break */
531+
fallthrough;
532532
default:
533533
zval_ptr_dtor(&val_free);
534534
zend_argument_type_error(2, "cannot be an object, %s given", zend_zval_type_name(val));

Zend/zend_execute.c

Lines changed: 9 additions & 7 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+
fallthrough;
302302
case BP_VAR_W:
303303
ZVAL_NULL(ptr);
304304
break;
@@ -1355,6 +1355,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type
13551355
}
13561356
case IS_UNDEF:
13571357
ZVAL_UNDEFINED_OP2();
1358+
fallthrough;
13581359
case IS_DOUBLE:
13591360
case IS_NULL:
13601361
case IS_FALSE:
@@ -2018,7 +2019,7 @@ static zend_never_inline zend_uchar slow_index_convert(HashTable *ht, const zval
20182019
if (EG(exception)) {
20192020
return IS_NULL;
20202021
}
2021-
/* break missing intentionally */
2022+
fallthrough;
20222023
}
20232024
case IS_NULL:
20242025
value->str = ZSTR_EMPTY_ALLOC();
@@ -2058,7 +2059,7 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
20582059
switch (type) {
20592060
case BP_VAR_R:
20602061
zend_undefined_offset(hval);
2061-
/* break missing intentionally */
2062+
fallthrough;
20622063
case BP_VAR_UNSET:
20632064
case BP_VAR_IS:
20642065
retval = &EG(uninitialized_zval);
@@ -2067,7 +2068,7 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
20672068
if (UNEXPECTED(zend_undefined_offset_write(ht, hval) == FAILURE)) {
20682069
return NULL;
20692070
}
2070-
/* break missing intentionally */
2071+
fallthrough;
20712072
case BP_VAR_W:
20722073
retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval));
20732074
break;
@@ -2089,7 +2090,7 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
20892090
switch (type) {
20902091
case BP_VAR_R:
20912092
zend_undefined_index(offset_key);
2092-
/* break missing intentionally */
2093+
fallthrough;
20932094
case BP_VAR_UNSET:
20942095
case BP_VAR_IS:
20952096
retval = &EG(uninitialized_zval);
@@ -2098,7 +2099,7 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
20982099
if (UNEXPECTED(zend_undefined_index_write(ht, offset_key))) {
20992100
return NULL;
21002101
}
2101-
/* break missing intentionally */
2102+
fallthrough;
21022103
case BP_VAR_W:
21032104
ZVAL_NULL(retval);
21042105
break;
@@ -2109,7 +2110,7 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
21092110
switch (type) {
21102111
case BP_VAR_R:
21112112
zend_undefined_index(offset_key);
2112-
/* break missing intentionally */
2113+
fallthrough;
21132114
case BP_VAR_UNSET:
21142115
case BP_VAR_IS:
21152116
retval = &EG(uninitialized_zval);
@@ -2347,6 +2348,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
23472348
}
23482349
case IS_UNDEF:
23492350
ZVAL_UNDEFINED_OP2();
2351+
fallthrough;
23502352
case IS_DOUBLE:
23512353
case IS_NULL:
23522354
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+
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+
fallthrough;
191191
default:
192192
zend_ini_copy_value(retval, str, len);
193193
}
@@ -329,6 +329,7 @@ static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_ty
329329
*t++ = *s;
330330
break;
331331
}
332+
fallthrough;
332333
case '\\':
333334
case '$':
334335
*t++ = *s;
@@ -607,7 +608,7 @@ end_raw_value_chars:
607608
if (YYCURSOR < YYLIMIT && *YYCURSOR != '"') {
608609
YYCURSOR++;
609610
}
610-
/* fall through */
611+
fallthrough;
611612
default:
612613
continue;
613614
}

Zend/zend_language_scanner.l

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ static zend_result zend_scan_escape_string(zval *zendlval, char *str, int len, c
992992
*t++ = *s;
993993
break;
994994
}
995+
fallthrough;
995996
case '\\':
996997
case '$':
997998
*t++ = *s;
@@ -2315,7 +2316,7 @@ inline_char_handler:
23152316
YYCURSOR--;
23162317
break;
23172318
}
2318-
/* fall through */
2319+
fallthrough;
23192320
default:
23202321
continue;
23212322
}
@@ -2498,7 +2499,7 @@ skip_escape_conversion:
24982499
if (YYCURSOR < YYLIMIT) {
24992500
YYCURSOR++;
25002501
}
2501-
/* fall through */
2502+
fallthrough;
25022503
default:
25032504
continue;
25042505
}
@@ -2735,7 +2736,7 @@ skip_escape_conversion:
27352736
if (YYCURSOR < YYLIMIT) {
27362737
YYCURSOR++;
27372738
}
2738-
/* fall through */
2739+
fallthrough;
27392740
default:
27402741
continue;
27412742
}
@@ -2782,7 +2783,7 @@ double_quotes_scan_done:
27822783
if (YYCURSOR < YYLIMIT) {
27832784
YYCURSOR++;
27842785
}
2785-
/* fall through */
2786+
fallthrough;
27862787
default:
27872788
continue;
27882789
}
@@ -2818,7 +2819,7 @@ double_quotes_scan_done:
28182819
if (*YYCURSOR == '\n') {
28192820
YYCURSOR++;
28202821
}
2821-
/* fall through */
2822+
fallthrough;
28222823
case '\n':
28232824
indentation = spacing = 0;
28242825
@@ -2888,7 +2889,7 @@ double_quotes_scan_done:
28882889
if (YYCURSOR < YYLIMIT && *YYCURSOR != '\n' && *YYCURSOR != '\r') {
28892890
YYCURSOR++;
28902891
}
2891-
/* fall through */
2892+
fallthrough;
28922893
default:
28932894
continue;
28942895
}
@@ -2942,7 +2943,7 @@ heredoc_scan_done:
29422943
if (*YYCURSOR == '\n') {
29432944
YYCURSOR++;
29442945
}
2945-
/* fall through */
2946+
fallthrough;
29462947
case '\n':
29472948
indentation = spacing = 0;
29482949
@@ -2993,7 +2994,7 @@ heredoc_scan_done:
29932994
29942995
goto nowdoc_scan_done;
29952996
}
2996-
/* fall through */
2997+
fallthrough;
29972998
default:
29982999
continue;
29993000
}

Zend/zend_object_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ ZEND_API HashTable *zend_std_get_properties_for(zend_object *obj, zend_prop_purp
17821782
}
17831783
return ht;
17841784
}
1785-
/* break missing intentionally */
1785+
fallthrough;
17861786
case ZEND_PROP_PURPOSE_ARRAY_CAST:
17871787
case ZEND_PROP_PURPOSE_SERIALIZE:
17881788
case ZEND_PROP_PURPOSE_VAR_EXPORT:

Zend/zend_opcode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ static void emit_live_range(
704704
return;
705705
}
706706
}
707-
/* explicit fallthrough */
707+
fallthrough;
708708
default:
709709
start++;
710710
kind = ZEND_LIVE_TMPVAR;
@@ -994,14 +994,14 @@ ZEND_API void pass_two(zend_op_array *op_array)
994994
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
995995
zend_check_finally_breakout(op_array, opline - op_array->opcodes, opline->op1.opline_num);
996996
}
997-
/* break omitted intentionally */
997+
fallthrough;
998998
case ZEND_JMP:
999999
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
10001000
break;
10011001
case ZEND_JMPZNZ:
10021002
/* absolute index to relative offset */
10031003
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
1004-
/* break omitted intentionally */
1004+
fallthrough;
10051005
case ZEND_JMPZ:
10061006
case ZEND_JMPNZ:
10071007
case ZEND_JMPZ_EX:

Zend/zend_operators.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ ZEND_API int ZEND_FASTCALL zend_atoi(const char *str, size_t str_len) /* {{{ */
9595
case 'g':
9696
case 'G':
9797
retval *= 1024;
98-
/* break intentionally missing */
98+
fallthrough;
9999
case 'm':
100100
case 'M':
101101
retval *= 1024;
102-
/* break intentionally missing */
102+
fallthrough;
103103
case 'k':
104104
case 'K':
105105
retval *= 1024;
@@ -123,11 +123,11 @@ ZEND_API zend_long ZEND_FASTCALL zend_atol(const char *str, size_t str_len) /* {
123123
case 'g':
124124
case 'G':
125125
retval *= 1024;
126-
/* break intentionally missing */
126+
fallthrough;
127127
case 'm':
128128
case 'M':
129129
retval *= 1024;
130-
/* break intentionally missing */
130+
fallthrough;
131131
case 'k':
132132
case 'K':
133133
retval *= 1024;
@@ -2455,7 +2455,7 @@ ZEND_API zend_result ZEND_FASTCALL increment_function(zval *op1) /* {{{ */
24552455
return SUCCESS;
24562456
}
24572457
}
2458-
/* break missing intentionally */
2458+
fallthrough;
24592459
case IS_RESOURCE:
24602460
case IS_ARRAY:
24612461
zend_type_error("Cannot increment %s", zend_zval_type_name(op1));
@@ -2517,7 +2517,7 @@ ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */
25172517
return SUCCESS;
25182518
}
25192519
}
2520-
/* break missing intentionally */
2520+
fallthrough;
25212521
case IS_RESOURCE:
25222522
case IS_ARRAY:
25232523
zend_type_error("Cannot decrement %s", zend_zval_type_name(op1));

0 commit comments

Comments
 (0)