diff --git a/pp_ctl.c b/pp_ctl.c index 6516005c8348..04f66a7b6f89 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3250,6 +3250,7 @@ PP(pp_goto) I32 ix; PERL_CONTEXT *cx; OP *enterops[GOTO_DEPTH]; + bool into_construct = FALSE; const char *label = NULL; STRLEN label_len = 0; U32 label_flags = 0; @@ -3652,9 +3653,7 @@ PP(pp_goto) ? 2 : 1; if (enterops[i]) - deprecate_fatal_in(WARN_DEPRECATED__GOTO_CONSTRUCT, - "5.42", - "Use of \"goto\" to jump into a construct"); + into_construct = TRUE; } /* pop unwanted frames */ @@ -3686,6 +3685,12 @@ PP(pp_goto) } } + if (into_construct) + deprecate_fatal_in(WARN_DEPRECATED__GOTO_CONSTRUCT, + "5.42", + "Use of \"goto\" to jump into a construct"); + + if (do_dump) { #ifdef VMS if (!retop) retop = PL_main_start; diff --git a/t/lib/croak/pp_ctl b/t/lib/croak/pp_ctl index 96f40cd458af..b9f9f01ac1b3 100644 --- a/t/lib/croak/pp_ctl +++ b/t/lib/croak/pp_ctl @@ -1,45 +1,40 @@ __END__ # NAME goto into foreach -no warnings 'deprecated'; goto f; foreach(1){f:} EXPECT -Can't "goto" into the middle of a foreach loop at - line 3. +Can't "goto" into the middle of a foreach loop at - line 2. ######## # NAME goto into given -no warnings 'deprecated'; goto f; CORE::given(1){f:} EXPECT -Can't "goto" into a "given" block at - line 3. +Can't "goto" into a "given" block at - line 2. ######## # NAME goto from given topic expression -no warnings 'deprecated'; CORE::given(goto f){f:} EXPECT -Can't "goto" into a "given" block at - line 2. +Can't "goto" into a "given" block at - line 1. ######## # NAME goto into expression -no warnings 'deprecated'; eval { goto a; 1 + do { a: } }; warn $@; eval { goto b; meth { b: } }; warn $@; eval { goto c; map { c: } () }; warn $@; eval { goto d; f(do { d: }) }; die $@; EXPECT +Can't "goto" into a binary or list expression at - line 1. Can't "goto" into a binary or list expression at - line 2. Can't "goto" into a binary or list expression at - line 3. Can't "goto" into a binary or list expression at - line 4. -Can't "goto" into a binary or list expression at - line 5. ######## # NAME dump with computed label -no warnings 'deprecated'; my $label = "foo"; CORE::dump $label; EXPECT -Can't find label foo at - line 3. +Can't find label foo at - line 2. ######## # NAME when outside given -use 5.01; no warnings 'deprecated'; +use 5.01; when(undef){} EXPECT Can't "when" outside a topicalizer at - line 2.