Implement :std subpragma of the open pragma
[p5sagit/p5-mst-13.2.git] / op.c
diff --git a/op.c b/op.c
index 5bd6448..5b11567 100644 (file)
--- a/op.c
+++ b/op.c
@@ -1,6 +1,6 @@
 /*    op.c
  *
- *    Copyright (c) 1991-2001, Larry Wall
+ *    Copyright (c) 1991-2002, Larry Wall
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -15,6 +15,7 @@
  * either way, as the saying is, if you follow me."  --the Gaffer
  */
 
+
 #include "EXTERN.h"
 #define PERL_IN_OP_C
 #include "perl.h"
 
 #define CALL_PEEP(o) CALL_FPTR(PL_peepp)(aTHX_ o)
 
-/* #define PL_OP_SLAB_ALLOC */
+#if defined(PL_OP_SLAB_ALLOC)
+
+#ifndef PERL_SLAB_SIZE
+#define PERL_SLAB_SIZE 2048
+#endif
 
-#if defined(PL_OP_SLAB_ALLOC) && !defined(PERL_IMPLICIT_CONTEXT)
-#define SLAB_SIZE 8192
-static char    *PL_OpPtr  = NULL;      /* XXX threadead */
-static int     PL_OpSpace = 0;         /* XXX threadead */
-#define NewOp(m,var,c,type) do { if ((PL_OpSpace -= c*sizeof(type)) >= 0)     \
-                              var =  (type *)(PL_OpPtr -= c*sizeof(type));    \
-                             else                                             \
-                              var = (type *) Slab_Alloc(m,c*sizeof(type));    \
-                           } while (0)
+#define NewOp(m,var,c,type) \
+       STMT_START { var = (type *) Slab_Alloc(m,c*sizeof(type)); } STMT_END
+
+#define FreeOp(p) Slab_Free(p)
 
 STATIC void *
 S_Slab_Alloc(pTHX_ int m, size_t sz)
 {
- Newz(m,PL_OpPtr,SLAB_SIZE,char);
- PL_OpSpace = SLAB_SIZE - sz;
- return PL_OpPtr += PL_OpSpace;
+    /*
+     * To make incrementing use count easy PL_OpSlab is an I32 *
+     * To make inserting the link to slab PL_OpPtr is I32 **
+     * So compute size in units of sizeof(I32 *) as that is how Pl_OpPtr increments
+     * Add an overhead for pointer to slab and round up as a number of pointers
+     */
+    sz = (sz + 2*sizeof(I32 *) -1)/sizeof(I32 *);
+    if ((PL_OpSpace -= sz) < 0) {
+       PL_OpPtr = (I32 **) PerlMemShared_malloc(PERL_SLAB_SIZE*sizeof(I32*));
+       if (!PL_OpPtr) {
+           return NULL;
+       }
+       Zero(PL_OpPtr,PERL_SLAB_SIZE,I32 **);
+       /* We reserve the 0'th I32 sized chunk as a use count */
+       PL_OpSlab = (I32 *) PL_OpPtr;
+       /* Reduce size by the use count word, and by the size we need.
+        * Latter is to mimic the '-=' in the if() above
+        */
+       PL_OpSpace = PERL_SLAB_SIZE - (sizeof(I32)+sizeof(I32 **)-1)/sizeof(I32 **) - sz;
+       /* Allocation pointer starts at the top.
+          Theory: because we build leaves before trunk allocating at end
+          means that at run time access is cache friendly upward
+        */
+       PL_OpPtr += PERL_SLAB_SIZE;
+    }
+    assert( PL_OpSpace >= 0 );
+    /* Move the allocation pointer down */
+    PL_OpPtr   -= sz;
+    assert( PL_OpPtr > (I32 **) PL_OpSlab );
+    *PL_OpPtr   = PL_OpSlab;   /* Note which slab it belongs to */
+    (*PL_OpSlab)++;            /* Increment use count of slab */
+    assert( PL_OpPtr+sz <= ((I32 **) PL_OpSlab + PERL_SLAB_SIZE) );
+    assert( *PL_OpSlab > 0 );
+    return (void *)(PL_OpPtr + 1);
+}
+
+STATIC void
+S_Slab_Free(pTHX_ void *op)
+{
+    I32 **ptr = (I32 **) op;
+    I32 *slab = ptr[-1];
+    assert( ptr-1 > (I32 **) slab );
+    assert( ptr < ( (I32 **) slab + PERL_SLAB_SIZE) );
+    assert( *slab > 0 );
+    if (--(*slab) == 0) {
+       PerlMemShared_free(slab);
+       if (slab == PL_OpSlab) {
+           PL_OpSpace = 0;
+       }
+    }
 }
 
 #else
 #define NewOp(m, var, c, type) Newz(m, var, c, type)
+#define FreeOp(p) Safefree(p)
 #endif
 /*
  * In the following definition, the ", Nullop" is just to make the compiler
@@ -734,14 +782,7 @@ Perl_op_free(pTHX_ OP *o)
        cop_free((COP*)o);
 
     op_clear(o);
-
-#ifdef PL_OP_SLAB_ALLOC
-    if ((char *) o == PL_OpPtr)
-     {
-     }
-#else
-    Safefree(o);
-#endif
+    FreeOp(o);
 }
 
 void
@@ -846,11 +887,7 @@ clear_pmop:
                    pmop = pmop->op_pmnext;
                }
            }
-#ifdef USE_ITHREADS
-           Safefree(PmopSTASHPV(cPMOPo));
-#else
-           /* NOTE: PMOP.op_pmstash is not refcounted */
-#endif
+           PmopSTASH_free(cPMOPo);
        }
        cPMOPo->op_pmreplroot = Nullop;
         /* we use the "SAFE" version of the PM_ macros here
@@ -867,7 +904,7 @@ clear_pmop:
            SvREPADTMP_on(PL_regex_pad[(cPMOPo)->op_pmoffset]);
             PM_SETRE(cPMOPo, (cPMOPo)->op_pmoffset);
         }
-#endif 
+#endif
 
        break;
     }
@@ -881,18 +918,22 @@ clear_pmop:
 STATIC void
 S_cop_free(pTHX_ COP* cop)
 {
-    Safefree(cop->cop_label);
-#ifdef USE_ITHREADS
-    Safefree(CopFILE(cop));            /* XXX share in a pvtable? */
-    Safefree(CopSTASHPV(cop));         /* XXX share in a pvtable? */
-#else
-    /* NOTE: COP.cop_stash is not refcounted */
-    SvREFCNT_dec(CopFILEGV(cop));
-#endif
+    Safefree(cop->cop_label);   /* FIXME: treaddead ??? */
+    CopFILE_free(cop);
+    CopSTASH_free(cop);
     if (! specialWARN(cop->cop_warnings))
        SvREFCNT_dec(cop->cop_warnings);
-    if (! specialCopIO(cop->cop_io))
+    if (! specialCopIO(cop->cop_io)) {
+#ifdef USE_ITHREADS
+       STRLEN len;
+        char *s = SvPV(cop->cop_io,len);
+#if 0
+       Perl_warn(aTHX_ "io='%.*s'",(int) len,s); /* ??? --jhi */
+#endif
+#else
        SvREFCNT_dec(cop->cop_io);
+#endif
+    }
 }
 
 void
@@ -988,7 +1029,7 @@ Perl_scalar(pTHX_ OP *o)
     case OP_SPLIT:
        if ((kid = cLISTOPo->op_first) && kid->op_type == OP_PUSHRE) {
            if (!kPMOP->op_pmreplroot)
-               deprecate("implicit split to @_");
+               deprecate_old("implicit split to @_");
        }
        /* FALL THROUGH */
     case OP_MATCH:
@@ -1235,7 +1276,7 @@ Perl_scalarvoid(pTHX_ OP *o)
     case OP_SPLIT:
        if ((kid = cLISTOPo->op_first) && kid->op_type == OP_PUSHRE) {
            if (!kPMOP->op_pmreplroot)
-               deprecate("implicit split to @_");
+               deprecate_old("implicit split to @_");
        }
        break;
     }
@@ -1448,7 +1489,7 @@ Perl_mod(pTHX_ OP *o, I32 type)
                        || kid->op_type == OP_METHOD)
                    {
                        UNOP *newop;
-                       
+
                        NewOp(1101, newop, 1, UNOP);
                        newop->op_type = OP_RV2CV;
                        newop->op_ppaddr = PL_ppaddr[OP_RV2CV];
@@ -1458,7 +1499,7 @@ Perl_mod(pTHX_ OP *o, I32 type)
                        newop->op_private |= OPpLVAL_INTRO;
                        break;
                    }
-               
+
                    if (kid->op_type != OP_RV2CV)
                        Perl_croak(aTHX_
                                   "panic: unexpected lvalue entersub "
@@ -1467,12 +1508,12 @@ Perl_mod(pTHX_ OP *o, I32 type)
                    kid->op_private |= OPpLVAL_INTRO;
                    break;      /* Postpone until runtime */
                }
-               
-               okid = kid;             
+
+               okid = kid;
                kid = kUNOP->op_first;
                if (kid->op_type == OP_NULL && kid->op_targ == OP_RV2SV)
                    kid = kUNOP->op_first;
-               if (kid->op_type == OP_NULL)            
+               if (kid->op_type == OP_NULL)
                    Perl_croak(aTHX_
                               "Unexpected constant lvalue entersub "
                               "entry via type/targ %ld:%"UVuf,
@@ -1492,7 +1533,7 @@ Perl_mod(pTHX_ OP *o, I32 type)
                    okid->op_private |= OPpLVAL_INTRO;
                    break;
                }
-               
+
                cv = GvCV(kGVOP_gv);
                if (!cv)
                    goto restore_2cv;
@@ -1539,7 +1580,7 @@ Perl_mod(pTHX_ OP *o, I32 type)
            goto nomod;
        PL_modcount++;
        break;
-       
+
     case OP_COND_EXPR:
        for (kid = cUNOPo->op_first->op_sibling; kid; kid = kid->op_sibling)
            mod(kid, type);
@@ -1610,7 +1651,7 @@ Perl_mod(pTHX_ OP *o, I32 type)
 
     case OP_PUSHMARK:
        break;
-       
+
     case OP_KEYS:
        if (type != OP_SASSIGN)
            goto nomod;
@@ -2459,30 +2500,6 @@ Perl_fold_constants(pTHX_ register OP *o)
     }
 
   nope:
-    if (!(PL_opargs[type] & OA_OTHERINT))
-       return o;
-
-    if (!(PL_hints & HINT_INTEGER)) {
-       if (type == OP_MODULO
-           || type == OP_DIVIDE
-           || !(o->op_flags & OPf_KIDS))
-       {
-           return o;
-       }
-
-       for (curop = ((UNOP*)o)->op_first; curop; curop = curop->op_sibling) {
-           if (curop->op_type == OP_CONST) {
-               if (SvIOK(((SVOP*)curop)->op_sv))
-                   continue;
-               return o;
-           }
-           if (PL_opargs[curop->op_type] & OA_RETINTEGER)
-               continue;
-           return o;
-       }
-       o->op_ppaddr = PL_ppaddr[++(o->op_type)];
-    }
-
     return o;
 }
 
@@ -2507,6 +2524,7 @@ Perl_gen_constant_list(pTHX_ register OP *o)
 
     o->op_type = OP_RV2AV;
     o->op_ppaddr = PL_ppaddr[OP_RV2AV];
+    o->op_seq = 0;             /* needs to be revisited in peep() */
     curop = ((UNOP*)o)->op_first;
     ((UNOP*)o)->op_first = newSVOP(OP_CONST, 0, SvREFCNT_inc(*PL_stack_sp--));
     op_free(curop);
@@ -2582,10 +2600,8 @@ Perl_append_list(pTHX_ I32 type, LISTOP *first, LISTOP *last)
     first->op_last = last->op_last;
     first->op_flags |= (last->op_flags & OPf_KIDS);
 
-#ifdef PL_OP_SLAB_ALLOC
-#else
-    Safefree(last);
-#endif
+    FreeOp(last);
+
     return (OP*)first;
 }
 
@@ -3089,7 +3105,7 @@ Perl_newPMOP(pTHX_ I32 type, I32 flags)
             pmop->op_pmoffset = SvIV(repointer);
            SvREPADTMP_off(repointer);
            sv_setiv(repointer,0);
-        } else { 
+        } else {
             repointer = newSViv(0);
             av_push(PL_regex_padav,SvREFCNT_inc(repointer));
             pmop->op_pmoffset = av_len(PL_regex_padav);
@@ -3097,7 +3113,7 @@ Perl_newPMOP(pTHX_ I32 type, I32 flags)
         }
     }
 #endif
-        
+
         /* link into pm list */
     if (type != OP_TRANS && PL_curstash) {
        pmop->op_pmnext = HvPMROOT(PL_curstash);
@@ -3130,7 +3146,7 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, OP *repl)
            p = SvPV(pat, plen);
            pm->op_pmflags |= PMf_SKIPWHITE;
        }
-        if (DO_UTF8(pat) || (PL_hints & HINT_UTF8))
+        if (DO_UTF8(pat))
            pm->op_pmdynflags |= PMdf_UTF8;
        PM_SETRE(pm, CALLREGCOMP(aTHX_ p, p + plen, pm));
        if (strEQ("\\s+", PM_GETRE(pm)->precomp))
@@ -3138,8 +3154,6 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, OP *repl)
        op_free(expr);
     }
     else {
-        if (PL_hints & HINT_UTF8)
-           pm->op_pmdynflags |= PMdf_UTF8;
        if (pm->op_pmflags & PMf_KEEP || !(PL_hints & HINT_RE_EVAL))
            expr = newUNOP((!(PL_hints & HINT_RE_EVAL)
                            ? OP_REGCRESET
@@ -3343,7 +3357,7 @@ Perl_package(pTHX_ OP *o)
        op_free(o);
     }
     else {
-       deprecate("\"package\" with no arguments");
+       deprecate_old("\"package\" with no arguments");
        sv_setpv(PL_curstname,"<none>");
        PL_curstash = Nullhv;
     }
@@ -3439,11 +3453,22 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *id, OP *arg)
            newSTATEOP(0, Nullch, imop) ));
 
     if (packname) {
-        if (ckWARN(WARN_MISC) && !gv_stashpvn(packname, packlen, FALSE)) {
-            Perl_warner(aTHX_ WARN_MISC,
-                        "Package `%s' not found "
-                        "(did you use the incorrect case?)", packname);
-        }
+        /* The "did you use incorrect case?" warning used to be here.
+         * The problem is that on case-insensitive filesystems one
+         * might get false positives for "use" (and "require"):
+         * "use Strict" or "require CARP" will work.  This causes
+         * portability problems for the script: in case-strict
+         * filesystems the script will stop working.
+         *
+         * The "incorrect case" warning checked whether "use Foo"
+         * imported "Foo" to your namespace, but that is wrong, too:
+         * there is no requirement nor promise in the language that
+         * a Foo.pm should or would contain anything in package "Foo".
+         *
+         * There is very little Configure-wise that can be done, either:
+         * the case-sensitivity of the build filesystem of Perl does not
+         * help in guessing the case-sensitivity of the runtime environment.
+         */
         safefree(packname);
     }
 
@@ -3453,6 +3478,8 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *id, OP *arg)
 }
 
 /*
+=head1 Embedding Functions
+
 =for apidoc load_module
 
 Loads the module whose name is pointed to by the string part of name.
@@ -3677,7 +3704,7 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right)
                            if (gv == PL_defgv || SvCUR(gv) == PL_generation)
                                break;
                            SvCUR(gv) = PL_generation;
-                       }       
+                       }
                    }
                    else
                        break;
@@ -3804,10 +3831,10 @@ Perl_newSTATEOP(pTHX_ I32 flags, char *label, OP *o)
 
     if (PERLDB_LINE && PL_curstash != PL_debstash) {
        SV **svp = av_fetch(CopFILEAV(PL_curcop), (I32)CopLINE(cop), FALSE);
-        if (svp && *svp != &PL_sv_undef ) { 
+        if (svp && *svp != &PL_sv_undef ) {
            (void)SvIOK_on(*svp);
            SvIVX(*svp) = PTR2IV(cop);
-       } 
+       }
     }
 
     return prepend_elem(OP_LINESEQ, (OP*)cop, o);
@@ -4287,6 +4314,7 @@ Perl_newFOROP(pTHX_ I32 flags,char *label,line_t forline,OP *sv,OP *expr,OP *blo
        LOOP *tmp;
        NewOp(1234,tmp,1,LOOP);
        Copy(loop,tmp,1,LOOP);
+       FreeOp(loop);
        loop = tmp;
     }
 #else
@@ -4632,6 +4660,9 @@ Perl_cv_ckproto(pTHX_ CV *cv, GV *gv, char *p)
 static void const_sv_xsub(pTHX_ CV* cv);
 
 /*
+
+=head1 Optree Manipulation Functions
+
 =for apidoc cv_const_sv
 
 If C<cv> is a constant sub eligible for inlining. returns the constant
@@ -4737,13 +4768,15 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
     name = o ? SvPVx(cSVOPo->op_sv, n_a) : Nullch;
     if (!name && PERLDB_NAMEANON && CopLINE(PL_curcop)) {
        SV *sv = sv_newmortal();
-       Perl_sv_setpvf(aTHX_ sv, "__ANON__[%s:%"IVdf"]",
+       Perl_sv_setpvf(aTHX_ sv, "%s[%s:%"IVdf"]",
+                      PL_curstash ? "__ANON__" : "__ANON__::__ANON__",
                       CopFILE(PL_curcop), (IV)CopLINE(PL_curcop));
        aname = SvPVX(sv);
     }
     else
        aname = Nullch;
-    gv = gv_fetchpv(name ? name : (aname ? aname : "__ANON__"),
+    gv = gv_fetchpv(name ? name : (aname ? aname : 
+                   (PL_curstash ? "__ANON__" : "__ANON__::__ANON__")),
                    GV_ADDMULTI | ((block || attrs) ? 0 : GV_NOINIT),
                    SVt_PVCV);
 
@@ -5137,11 +5170,7 @@ Perl_newCONSTSUB(pTHX_ HV *stash, char *name, SV *sv)
        SAVESPTR(PL_curstash);
        SAVECOPSTASH(PL_curcop);
        PL_curstash = stash;
-#ifdef USE_ITHREADS
-       CopSTASHPV(PL_curcop) = stash ? HvNAME(stash) : Nullch;
-#else
-       CopSTASH(PL_curcop) = stash;
-#endif
+       CopSTASH_set(PL_curcop,stash);
     }
 
     cv = newXS(name, const_sv_xsub, __FILE__);
@@ -5165,7 +5194,9 @@ Used by C<xsubpp> to hook up XSUBs as Perl subs.
 CV *
 Perl_newXS(pTHX_ char *name, XSUBADDR_t subaddr, char *filename)
 {
-    GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV);
+    GV *gv = gv_fetchpv(name ? name :
+                       (PL_curstash ? "__ANON__" : "__ANON__::__ANON__"),
+                       GV_ADDMULTI, SVt_PVCV);
     register CV *cv;
 
     if ((cv = (name ? GvCV(gv) : Nullcv))) {
@@ -5349,7 +5380,7 @@ Perl_oopsAV(pTHX_ OP *o)
        o->op_type = OP_PADAV;
        o->op_ppaddr = PL_ppaddr[OP_PADAV];
        return ref(o, OP_RV2AV);
-       
+
     case OP_RV2SV:
        o->op_type = OP_RV2AV;
        o->op_ppaddr = PL_ppaddr[OP_RV2AV];
@@ -5398,8 +5429,8 @@ Perl_newAVREF(pTHX_ OP *o)
        return o;
     }
     else if ((o->op_type == OP_RV2AV || o->op_type == OP_PADAV)
-               && ckWARN(WARN_DEPRECATED)) {
-       Perl_warner(aTHX_ WARN_DEPRECATED,
+               && ckWARN2(WARN_DEPRECATED, WARN_SYNTAX)) {
+       Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
                "Using an array as a reference is deprecated");
     }
     return newUNOP(OP_RV2AV, 0, scalar(o));
@@ -5422,8 +5453,8 @@ Perl_newHVREF(pTHX_ OP *o)
        return o;
     }
     else if ((o->op_type == OP_RV2HV || o->op_type == OP_PADHV)
-               && ckWARN(WARN_DEPRECATED)) {
-       Perl_warner(aTHX_ WARN_DEPRECATED,
+               && ckWARN2(WARN_DEPRECATED, WARN_SYNTAX)) {
+       Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
                "Using a hash as a reference is deprecated");
     }
     return newUNOP(OP_RV2HV, 0, scalar(o));
@@ -5510,7 +5541,7 @@ Perl_ck_spair(pTHX_ OP *o)
             !(PL_opargs[newop->op_type] & OA_RETSCALAR) ||
             newop->op_type == OP_PADAV || newop->op_type == OP_PADHV ||
             newop->op_type == OP_RV2AV || newop->op_type == OP_RV2HV)) {
-       
+
            return o;
        }
        op_free(kUNOP->op_first);
@@ -5877,15 +5908,15 @@ Perl_ck_fun(pTHX_ OP *o)
                    Perl_warner(aTHX_ WARN_SYNTAX,
                        "Useless use of %s with no values",
                        PL_op_desc[type]);
-                   
+
                if (kid->op_type == OP_CONST &&
                    (kid->op_private & OPpCONST_BARE))
                {
                    char *name = SvPVx(((SVOP*)kid)->op_sv, n_a);
                    OP *newop = newAVREF(newGVOP(OP_GV, 0,
                        gv_fetchpv(name, TRUE, SVt_PVAV) ));
-                   if (ckWARN(WARN_DEPRECATED))
-                       Perl_warner(aTHX_ WARN_DEPRECATED,
+                   if (ckWARN2(WARN_DEPRECATED, WARN_SYNTAX))
+                       Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
                            "Array @%s missing the @ in argument %"IVdf" of %s()",
                            name, (IV)numargs, PL_op_desc[type]);
                    op_free(kid);
@@ -5904,8 +5935,8 @@ Perl_ck_fun(pTHX_ OP *o)
                    char *name = SvPVx(((SVOP*)kid)->op_sv, n_a);
                    OP *newop = newHVREF(newGVOP(OP_GV, 0,
                        gv_fetchpv(name, TRUE, SVt_PVHV) ));
-                   if (ckWARN(WARN_DEPRECATED))
-                       Perl_warner(aTHX_ WARN_DEPRECATED,
+                   if (ckWARN2(WARN_DEPRECATED, WARN_SYNTAX))
+                       Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
                            "Hash %%%s missing the %% in argument %"IVdf" of %s()",
                            name, (IV)numargs, PL_op_desc[type]);
                    op_free(kid);
@@ -5929,8 +5960,6 @@ Perl_ck_fun(pTHX_ OP *o)
                }
                break;
            case OA_FILEREF:
-                       if(kid==cLISTOPo->op_last)
-                           cLISTOPo->op_last = newop;
                if (kid->op_type != OP_GV && kid->op_type != OP_RV2GV) {
                    if (kid->op_type == OP_CONST &&
                        (kid->op_private & OPpCONST_BARE))
@@ -5938,6 +5967,8 @@ Perl_ck_fun(pTHX_ OP *o)
                        OP *newop = newGVOP(OP_GV, 0,
                            gv_fetchpv(SvPVx(((SVOP*)kid)->op_sv, n_a), TRUE,
                                        SVt_PVIO) );
+                       if (kid == cLISTOPo->op_last)
+                           cLISTOPo->op_last = newop;
                        op_free(kid);
                        kid = newop;
                    }
@@ -6048,8 +6079,8 @@ Perl_ck_glob(pTHX_ OP *o)
     if (!gv) {
        GV *glob_gv;
        ENTER;
-       Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, newSVpvn("File::Glob", 10), Nullsv,
-                        Nullsv, Nullsv);
+       Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT,
+               newSVpvn("File::Glob", 10), Nullsv, Nullsv, Nullsv);
        gv = gv_fetchpv("CORE::GLOBAL::glob", FALSE, SVt_PVCV);
        glob_gv = gv_fetchpv("File::Glob::csh_glob", FALSE, SVt_PVCV);
        GvCV(gv) = GvCV(glob_gv);
@@ -6162,7 +6193,7 @@ Perl_ck_lfun(pTHX_ OP *o)
 OP *
 Perl_ck_defined(pTHX_ OP *o)           /* 19990527 MJD */
 {
-    if ((o->op_flags & OPf_KIDS) && ckWARN(WARN_DEPRECATED)) {
+    if ((o->op_flags & OPf_KIDS) && ckWARN2(WARN_DEPRECATED, WARN_SYNTAX)) {
        switch (cUNOPo->op_first->op_type) {
        case OP_RV2AV:
            /* This is needed for
@@ -6172,9 +6203,9 @@ Perl_ck_defined(pTHX_ OP *o)              /* 19990527 MJD */
            break;                      /* Globals via GV can be undef */
        case OP_PADAV:
        case OP_AASSIGN:                /* Is this a good idea? */
-           Perl_warner(aTHX_ WARN_DEPRECATED,
+           Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
                        "defined(@array) is deprecated");
-           Perl_warner(aTHX_ WARN_DEPRECATED,
+           Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
                        "\t(Maybe you should just omit the defined()?)\n");
        break;
        case OP_RV2HV:
@@ -6184,9 +6215,9 @@ Perl_ck_defined(pTHX_ OP *o)              /* 19990527 MJD */
               */
            break;                      /* Globals via GV can be undef */
        case OP_PADHV:
-           Perl_warner(aTHX_ WARN_DEPRECATED,
+           Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
                        "defined(%%hash) is deprecated");
-           Perl_warner(aTHX_ WARN_DEPRECATED,
+           Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
                        "\t(Maybe you should just omit the defined()?)\n");
            break;
        default:
@@ -6227,7 +6258,7 @@ Perl_ck_listiob(pTHX_ OP *o)
            kid = kid->op_sibling;
        }
     }
-       
+
     if (!kid)
        append_elem(o->op_type, o, newDEFSVOP());
 
@@ -6435,7 +6466,7 @@ Perl_ck_shift(pTHX_ OP *o)
 
     if (!(o->op_flags & OPf_KIDS)) {
        OP *argop;
-       
+
        op_free(o);
 #ifdef USE_5005THREADS
        if (!CvUNIQUE(PL_compcv)) {
@@ -6781,9 +6812,16 @@ Perl_ck_subr(pTHX_ OP *o)
                     goto again;
                     break;
                case ']':
-                    if (contextclass)
-                         contextclass = 0;
-                    else
+                    if (contextclass) {
+                        char *p = proto;
+                        char s = *p;
+                        contextclass = 0;
+                        *p = '\0';
+                        while (*--p != '[');
+                        bad_type(arg, Perl_form(aTHX_ "one of %s", p),
+                                gv_ename(namegv), o2);
+                        *proto = s;
+                    } else
                          goto oops;
                     break;
                case '*':
@@ -7024,7 +7062,7 @@ Perl_peep(pTHX_ register OP *o)
            else if (o->op_next->op_type == OP_RV2AV) {
                OP* pop = o->op_next->op_next;
                IV i;
-               if (pop->op_type == OP_CONST &&
+               if (pop && pop->op_type == OP_CONST &&
                    (PL_op = pop->op_next) &&
                    pop->op_next->op_type == OP_AELEM &&
                    !(pop->op_next->op_private &
@@ -7129,7 +7167,7 @@ Perl_peep(pTHX_ register OP *o)
                }
            }
            break;
-       
+
        case OP_HELEM: {
            UNOP *rop;
            SV *lexname;
@@ -7138,7 +7176,7 @@ Perl_peep(pTHX_ register OP *o)
            I32 ind;
            char *key = NULL;
            STRLEN keylen;
-       
+
            o->op_seq = PL_op_seqmax++;
 
            if (((BINOP*)o)->op_last->op_type != OP_CONST)
@@ -7190,7 +7228,7 @@ Perl_peep(pTHX_ register OP *o)
            *svp = sv;
            break;
        }
-       
+
        case OP_HSLICE: {
            UNOP *rop;
            SV *lexname;
@@ -7320,4 +7358,3 @@ const_sv_xsub(pTHX_ CV* cv)
     ST(0) = (SV*)XSANY.any_ptr;
     XSRETURN(1);
 }
-