summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2004-02-17 23:30:50 +0000
committerDave Mitchell <davem@fdisolutions.com>2004-02-17 23:30:50 +0000
commitdc9aa44637d2171ba3efbf36c71e8591a7ce05d7 (patch)
tree89e779252a08db19466b5562dc06e0b9e321738d /op.c
parentbe56ab1f8df33612d7b40c6ada095aa7922d7626 (diff)
downloadperl-dc9aa44637d2171ba3efbf36c71e8591a7ce05d7.tar.gz
add deprecation warning for C<my $x if foo> and C<foo && (my $x)>
p4raw-id: //depot/perl@22328
Diffstat (limited to 'op.c')
-rw-r--r--op.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/op.c b/op.c
index 871a0f62cf..d6d9aee6ff 100644
--- a/op.c
+++ b/op.c
@@ -3313,7 +3313,9 @@ Perl_newSTATEOP(pTHX_ I32 flags, char *label, OP *o)
}
}
- return prepend_elem(OP_LINESEQ, (OP*)cop, o);
+ o = prepend_elem(OP_LINESEQ, (OP*)cop, o);
+ CHECKOP(cop->op_type, cop);
+ return o;
}
@@ -5972,6 +5974,42 @@ Perl_ck_join(pTHX_ OP *o)
}
OP *
+Perl_ck_state(pTHX_ OP *o)
+{
+ /* warn on C<my $x=1 if foo;> , C<$a && my $x=1;> style statements */
+ OP *kid;
+ o = o->op_sibling;
+ if (!o || o->op_type != OP_NULL || !(o->op_flags & OPf_KIDS))
+ return o;
+ kid = cUNOPo->op_first;
+ if (!(kid->op_type == OP_AND || kid->op_type == OP_OR))
+ return o;
+ kid = kUNOP->op_first->op_sibling;
+ if (kid->op_type == OP_SASSIGN)
+ kid = kBINOP->op_first->op_sibling;
+ else if (kid->op_type == OP_AASSIGN)
+ kid = kBINOP->op_first->op_sibling;
+
+ if (kid->op_type == OP_LIST
+ || (kid->op_type == OP_NULL && kid->op_targ == OP_LIST))
+ {
+ kid = kUNOP->op_first;
+ if (kid->op_type == OP_PUSHMARK)
+ kid = kid->op_sibling;
+ }
+ if ((kid->op_type == OP_PADSV || kid->op_type == OP_PADAV
+ || kid->op_type == OP_PADHV)
+ && (kid->op_private & OPpLVAL_INTRO)
+ && (ckWARN(WARN_DEPRECATED)))
+ {
+ Perl_warner(aTHX_ packWARN(WARN_DEPRECATED),
+ "Use of my in conditional deprecated");
+ }
+ return o;
+}
+
+
+OP *
Perl_ck_subr(pTHX_ OP *o)
{
OP *prev = ((cUNOPo->op_first->op_sibling)