diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-11-01 19:08:46 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-13 04:49:38 -0800 |
commit | 7f08c641e557e7ea5657578f33a3430437642ffc (patch) | |
tree | 8721c410290ab1ebb2c100ad4a2d2c59b40326e5 /op.c | |
parent | bbd7756c2420ed595497f5969770114617b5abb2 (diff) | |
download | perl-7f08c641e557e7ea5657578f33a3430437642ffc.tar.gz |
Don’t inline sub(){0; $x} if $x changes elsewhere
Some op trees will turn a sub into a constant even if they
are more than just a simple constant or lexical variable. In
particular, a statement optimised away followed by a lexi-
cal variable is eligible for inlining. As discussed in
<20141101170924.17763.qmail@lists-nntp.develooper.com>, make these
more complex op trees follow closure rules properly. If the outer
lexical is used in lvalue context in places other than its declara-
tion, then we should forego inlining.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -7756,16 +7756,18 @@ Perl_op_const_sv(pTHX_ const OP *o, CV *cv, CV *outcv) nextstate padsv */ - if (ckWARN_d(WARN_DEPRECATED) - && OP_SIBLING( + if (OP_SIBLING( cUNOPx(cUNOPx(CvROOT(cv))->op_first)->op_first ) == o && !OP_SIBLING(o)) - Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), + Perl_ck_warner_d(aTHX_ + packWARN(WARN_DEPRECATED), "Constants from lexical " "variables potentially " "modified elsewhere are " "deprecated"); + else + return NULL; } } sv = PAD_BASE_SV(CvPADLIST(cv), o->op_targ); |