File tree Expand file tree Collapse file tree 2 files changed +38
-10
lines changed Expand file tree Collapse file tree 2 files changed +38
-10
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,21 @@ function test() {
22
22
}
23
23
}
24
24
25
+ switch ($ bar ) {
26
+ case 0 :
27
+ while ($ xyz ) {
28
+ continue 2 ; // INVALID
29
+ }
30
+ case 1 :
31
+ while ($ xyz ) {
32
+ continue ;
33
+ }
34
+ case 2 :
35
+ while ($ xyz ) {
36
+ break 2 ;
37
+ }
38
+ }
39
+
25
40
while ($ foo ) {
26
41
switch ($ bar ) {
27
42
case 0 :
@@ -42,8 +57,10 @@ function test() {
42
57
43
58
?>
44
59
--EXPECTF--
45
- Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in %s on line 6
60
+ Warning: "continue" targeting switch is equivalent to "break" in %s on line 6
46
61
47
62
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in %s on line 14
48
63
49
- Warning: "continue 2" targeting switch is equivalent to "break 2". Did you mean to use "continue 3"? in %s on line 26
64
+ Warning: "continue 2" targeting switch is equivalent to "break 2" in %s on line 25
65
+
66
+ Warning: "continue 2" targeting switch is equivalent to "break 2". Did you mean to use "continue 3"? in %s on line 41
Original file line number Diff line number Diff line change @@ -4891,15 +4891,26 @@ void zend_compile_break_continue(zend_ast *ast) /* {{{ */
4891
4891
4892
4892
if (CG (context ).brk_cont_array [cur ].is_switch ) {
4893
4893
if (depth == 1 ) {
4894
- zend_error (E_WARNING ,
4895
- "\"continue\" targeting switch is equivalent to \"break\". " \
4896
- "Did you mean to use \"continue " ZEND_LONG_FMT "\"?" ,
4897
- depth + 1 );
4894
+ if (CG (context ).brk_cont_array [cur ].parent == -1 ) {
4895
+ zend_error (E_WARNING ,
4896
+ "\"continue\" targeting switch is equivalent to \"break\"" );
4897
+ } else {
4898
+ zend_error (E_WARNING ,
4899
+ "\"continue\" targeting switch is equivalent to \"break\". " \
4900
+ "Did you mean to use \"continue " ZEND_LONG_FMT "\"?" ,
4901
+ depth + 1 );
4902
+ }
4898
4903
} else {
4899
- zend_error (E_WARNING ,
4900
- "\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\". " \
4901
- "Did you mean to use \"continue " ZEND_LONG_FMT "\"?" ,
4902
- depth , depth , depth + 1 );
4904
+ if (CG (context ).brk_cont_array [cur ].parent == -1 ) {
4905
+ zend_error (E_WARNING ,
4906
+ "\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\"" ,
4907
+ depth , depth );
4908
+ } else {
4909
+ zend_error (E_WARNING ,
4910
+ "\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\". " \
4911
+ "Did you mean to use \"continue " ZEND_LONG_FMT "\"?" ,
4912
+ depth , depth , depth + 1 );
4913
+ }
4903
4914
}
4904
4915
}
4905
4916
}
You can’t perform that action at this time.
0 commit comments