remove an 'if $a if 0' from AutoSplit.t
[p5sagit/p5-mst-13.2.git] / op.c
diff --git a/op.c b/op.c
index 4bd252c..c8a74fd 100644 (file)
--- a/op.c
+++ b/op.c
@@ -677,10 +677,14 @@ Perl_scalarvoid(pTHX_ OP *o)
        else {
            if (ckWARN(WARN_VOID)) {
                useless = "a constant";
+               /* don't warn on optimised away booleans, eg 
+                * use constant Foo, 5; Foo || print; */
+               if (cSVOPo->op_private & OPpCONST_SHORTCIRCUIT)
+                   useless = 0;
                /* the constants 0 and 1 are permitted as they are
                   conventionally used as dummies in constructs like
                        1 while some_condition_with_side_effects;  */
-               if (SvNIOK(sv) && (SvNV(sv) == 0.0 || SvNV(sv) == 1.0))
+               else if (SvNIOK(sv) && (SvNV(sv) == 0.0 || SvNV(sv) == 1.0))
                    useless = 0;
                else if (SvPOK(sv)) {
                   /* perl4's way of mixing documentation and code
@@ -3316,9 +3320,7 @@ Perl_newSTATEOP(pTHX_ I32 flags, char *label, OP *o)
        }
     }
 
-    o = prepend_elem(OP_LINESEQ, (OP*)cop, o);
-    CHECKOP(cop->op_type, cop);
-    return o;
+    return prepend_elem(OP_LINESEQ, (OP*)cop, o);
 }
 
 
@@ -3363,11 +3365,13 @@ S_new_logop(pTHX_ I32 type, I32 flags, OP** firstp, OP** otherp)
        if ((type == OP_AND) == (SvTRUE(((SVOP*)first)->op_sv))) {
            op_free(first);
            *firstp = Nullop;
+           other->op_private |= OPpCONST_SHORTCIRCUIT;
            return other;
        }
        else {
            op_free(other);
            *otherp = Nullop;
+           first->op_private |= OPpCONST_SHORTCIRCUIT;
            return first;
        }
     }
@@ -5980,42 +5984,6 @@ 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),
-                           "Deprecated use of my() in conditional");
-    }
-    return o;
-}
-
-
-OP *
 Perl_ck_subr(pTHX_ OP *o)
 {
     OP *prev = ((cUNOPo->op_first->op_sibling)