STRLEN ps_len;
register CV *cv=0;
SV *const_sv;
+ I32 gv_fetch_flags;
const char * const name = o ? SvPVx_nolen_const(cSVOPo->op_sv) : Nullch;
}
else
aname = Nullch;
- gv = name ? gv_fetchsv(cSVOPo->op_sv,
- GV_ADDMULTI | ((block || attrs) ? 0 : GV_NOINIT),
- SVt_PVCV)
+
+ gv_fetch_flags = (block || attrs || (CvFLAGS(PL_compcv) & CVf_BUILTIN_ATTRS))
+ ? GV_ADDMULTI : GV_ADDMULTI | GV_NOINIT;
+ gv = name ? gv_fetchsv(cSVOPo->op_sv, gv_fetch_flags, SVt_PVCV)
: gv_fetchpv(aname ? aname
: (PL_curstash ? "__ANON__" : "__ANON__::__ANON__"),
- GV_ADDMULTI | ((block || attrs) ? 0 : GV_NOINIT),
- SVt_PVCV);
+ gv_fetch_flags, SVt_PVCV);
if (o)
SAVEFREEOP(o);
@attrs = eval 'attributes::get $thunk';
is "@attrs", "locked method Z";
+# Test attributes on predeclared subroutines:
+eval 'package A; sub PS : lvalue';
+@attrs = eval 'attributes::get \&A::PS';
+is "@attrs", "lvalue";
+
# Test ability to modify existing sub's (or XSUB's) attributes.
eval 'package A; sub X { $_[0] } sub X : lvalue';
@attrs = eval 'attributes::get \&A::X';