diff options
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 37 |
1 files changed, 31 insertions, 6 deletions
@@ -66,6 +66,7 @@ static I32 list_assignment _((OP *o)); static void bad_type _((I32 n, char *t, char *name, OP *kid)); static OP *modkids _((OP *o, I32 type)); static OP *no_fh_allowed _((OP *o)); +static void no_bareword_allowed _((OP *o)); static OP *scalarboolean _((OP *o)); static OP *too_few_arguments _((OP *o, char* name)); static OP *too_many_arguments _((OP *o, char* name)); @@ -116,6 +117,14 @@ bad_type(I32 n, char *t, char *name, OP *kid) (int)n, name, t, PL_op_desc[kid->op_type])); } +STATIC void +no_bareword_allowed(OP *o) +{ + warn("Bareword \"%s\" not allowed while \"strict subs\" in use", + SvPV_nolen(cSVOPo->op_sv)); + ++PL_error_count; +} + void assertref(OP *o) { @@ -987,7 +996,9 @@ scalarvoid(OP *o) case OP_CONST: sv = cSVOPo->op_sv; - { + if (cSVOPo->op_private & OPpCONST_STRICT) + no_bareword_allowed(o); + else { dTHR; if (ckWARN(WARN_VOID)) { useless = "a constant"; @@ -1841,6 +1852,10 @@ fold_constants(register OP *o) goto nope; switch (type) { + case OP_NEGATE: + /* XXX might want a ck_negate() for this */ + cUNOPo->op_first->op_private &= ~OPpCONST_STRICT; + break; case OP_SPRINTF: case OP_UCFIRST: case OP_LCFIRST: @@ -1861,10 +1876,11 @@ fold_constants(register OP *o) for (curop = LINKLIST(o); curop != o; curop = LINKLIST(curop)) { if (curop->op_type != OP_CONST && - curop->op_type != OP_LIST && - curop->op_type != OP_SCALAR && - curop->op_type != OP_NULL && - curop->op_type != OP_PUSHMARK) { + curop->op_type != OP_LIST && + curop->op_type != OP_SCALAR && + curop->op_type != OP_NULL && + curop->op_type != OP_PUSHMARK) + { goto nope; } } @@ -5356,6 +5372,10 @@ ck_subr(OP *o) } } } + else if (cvop->op_type == OP_METHOD) { + if (o2->op_type == OP_CONST) + o2->op_private &= ~OPpCONST_STRICT; + } o->op_private |= (PL_hints & HINT_STRICT_REFS); if (PERLDB_SUB && PL_curstash != PL_debstash) o->op_private |= OPpENTERSUB_DB; @@ -5390,6 +5410,8 @@ ck_subr(OP *o) arg++; if (o2->op_type == OP_RV2GV) goto wrapref; /* autoconvert GLOB -> GLOBref */ + else if (o2->op_type == OP_CONST) + o2->op_private &= ~OPpCONST_STRICT; scalar(o2); break; case '\\': @@ -5502,8 +5524,11 @@ peep(register OP *o) o->op_seq = PL_op_seqmax++; break; - case OP_CONCAT: case OP_CONST: + if (cSVOPo->op_private & OPpCONST_STRICT) + no_bareword_allowed(o); + /* FALL THROUGH */ + case OP_CONCAT: case OP_JOIN: case OP_UC: case OP_UCFIRST: |