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 @@ -4967,15 +4967,26 @@ void zend_compile_break_continue(zend_ast *ast) /* {{{ */
4967
4967
4968
4968
if (CG (context ).brk_cont_array [cur ].is_switch ) {
4969
4969
if (depth == 1 ) {
4970
- zend_error (E_WARNING ,
4971
- "\"continue\" targeting switch is equivalent to \"break\". " \
4972
- "Did you mean to use \"continue " ZEND_LONG_FMT "\"?" ,
4973
- depth + 1 );
4970
+ if (CG (context ).brk_cont_array [cur ].parent == -1 ) {
4971
+ zend_error (E_WARNING ,
4972
+ "\"continue\" targeting switch is equivalent to \"break\"" );
4973
+ } else {
4974
+ zend_error (E_WARNING ,
4975
+ "\"continue\" targeting switch is equivalent to \"break\". " \
4976
+ "Did you mean to use \"continue " ZEND_LONG_FMT "\"?" ,
4977
+ depth + 1 );
4978
+ }
4974
4979
} else {
4975
- zend_error (E_WARNING ,
4976
- "\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\". " \
4977
- "Did you mean to use \"continue " ZEND_LONG_FMT "\"?" ,
4978
- depth , depth , depth + 1 );
4980
+ if (CG (context ).brk_cont_array [cur ].parent == -1 ) {
4981
+ zend_error (E_WARNING ,
4982
+ "\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\"" ,
4983
+ depth , depth );
4984
+ } else {
4985
+ zend_error (E_WARNING ,
4986
+ "\"continue " ZEND_LONG_FMT "\" targeting switch is equivalent to \"break " ZEND_LONG_FMT "\". " \
4987
+ "Did you mean to use \"continue " ZEND_LONG_FMT "\"?" ,
4988
+ depth , depth , depth + 1 );
4989
+ }
4979
4990
}
4980
4991
}
4981
4992
}
You can’t perform that action at this time.
0 commit comments