diff options
author | Gerard Goossen <gerard@ggoossen.net> | 2011-08-09 20:35:06 +0200 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-11 09:07:14 -0700 |
commit | eb796c7f1a47acbd996034731639c1bb76e31a19 (patch) | |
tree | ce561de43080ad2dc8c9a59d417dbd873faf1b80 /op.c | |
parent | 86a64801a038eae8c8c1c6f0ba6a8b40aeb8fa8d (diff) | |
download | perl-eb796c7f1a47acbd996034731639c1bb76e31a19.tar.gz |
Move bareword checking from the peephole optimizer to finalize_optree. Fixes [perl #95998]
The bareword checking is moved from the peephole optimizer to finalize_optree.
newRANGE needs additional bareword checking because the constants may
be optimized away by 'gen_constant_list'.
The OPpCONST_STRICT flag is removed after giving an error about a
bareword to prevent giving multiple errors about the same bareword.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -365,7 +365,7 @@ S_bad_type(pTHX_ I32 n, const char *t, const char *name, const OP *kid) } STATIC void -S_no_bareword_allowed(pTHX_ const OP *o) +S_no_bareword_allowed(pTHX_ OP *o) { PERL_ARGS_ASSERT_NO_BAREWORD_ALLOWED; @@ -374,6 +374,7 @@ S_no_bareword_allowed(pTHX_ const OP *o) qerror(Perl_mess(aTHX_ "Bareword \"%"SVf"\" not allowed while \"strict subs\" in use", SVfARG(cSVOPo_sv))); + o->op_private &= ~OPpCONST_STRICT; /* prevent warning twice about the same OP */ } /* "register" allocation */ @@ -1479,6 +1480,9 @@ S_finalize_op(pTHX_ OP* o) break; case OP_CONST: + if (cSVOPo->op_private & OPpCONST_STRICT) + no_bareword_allowed(o); + /* FALLTHROUGH */ #ifdef USE_ITHREADS case OP_HINTSEVAL: case OP_METHOD_NAMED: @@ -5565,6 +5569,12 @@ Perl_newRANGE(pTHX_ I32 flags, OP *left, OP *right) flip->op_private = left->op_type == OP_CONST ? OPpFLIP_LINENUM : 0; flop->op_private = right->op_type == OP_CONST ? OPpFLIP_LINENUM : 0; + /* check barewords before they might be optimized aways */ + if (flip->op_private && cSVOPx(left)->op_private & OPpCONST_STRICT) + no_bareword_allowed(left); + if (flop->op_private && cSVOPx(right)->op_private & OPpCONST_STRICT) + no_bareword_allowed(right); + flip->op_next = o; if (!flip->op_private || !flop->op_private) LINKLIST(o); /* blow off optimizer unless constant */ @@ -9669,11 +9679,6 @@ Perl_rpeep(pTHX_ register OP *o) } break; - case OP_CONST: - if (cSVOPo->op_private & OPpCONST_STRICT) - no_bareword_allowed(o); - break; - case OP_CONCAT: if (o->op_next && o->op_next->op_type == OP_STRINGIFY) { if (o->op_next->op_private & OPpTARGET_MY) { |