summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pad.c9
-rw-r--r--pad.h2
-rw-r--r--sv.h7
3 files changed, 12 insertions, 6 deletions
diff --git a/pad.c b/pad.c
index 880902d509..97e2615134 100644
--- a/pad.c
+++ b/pad.c
@@ -321,7 +321,7 @@ offset.
If C<typestash> is valid, the name is for a typed lexical; set the
name's stash to that value.
If C<ourstash> is valid, it's an our lexical, set the name's
-GvSTASH to that value
+OURSTASH to that value
If fake, it means we're cloning an existing entry
@@ -347,7 +347,7 @@ Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake
}
if (ourstash) {
SvPAD_OUR_on(namesv);
- GvSTASH(namesv) = ourstash;
+ OURSTASH_set(namesv, ourstash);
Perl_sv_add_backref(aTHX_ (SV*)ourstash, namesv);
}
@@ -549,7 +549,7 @@ Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash)
&& sv != &PL_sv_undef
&& !SvFAKE(sv)
&& (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0)
- && ((SvPAD_OUR(sv)) && GvSTASH(sv) == ourstash)
+ && OURSTASH(sv) == ourstash
&& strEQ(name, SvPVX_const(sv)))
{
Perl_warner(aTHX_ packWARN(WARN_MISC),
@@ -838,8 +838,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
SvPVX_const(*out_name_sv),
SvPAD_TYPED(*out_name_sv)
? SvSTASH(*out_name_sv) : NULL,
- SvPAD_OUR(*out_name_sv)
- ? GvSTASH(*out_name_sv) : NULL,
+ OURSTASH(*out_name_sv),
1 /* fake */
);
diff --git a/pad.h b/pad.h
index b234e636a1..acfb58e47d 100644
--- a/pad.h
+++ b/pad.h
@@ -226,7 +226,7 @@ ling pad (lvalue) to C<gen>. Note that C<SvCUR_set> is hijacked for this purpos
#define PAD_COMPNAME_TYPE(po) pad_compname_type(po)
#define PAD_COMPNAME_OURSTASH(po) \
- (GvSTASH(*av_fetch(PL_comppad_name, (po), FALSE)))
+ (OURSTASH(*av_fetch(PL_comppad_name, (po), FALSE)))
#define PAD_COMPNAME_GEN(po) SvCUR(AvARRAY(PL_comppad_name)[po])
diff --git a/sv.h b/sv.h
index 5474074ed9..9e5ae2b2ca 100644
--- a/sv.h
+++ b/sv.h
@@ -937,6 +937,13 @@ in gv.h: */
((SvFLAGS(sv) & (SVpad_NAME|SVpad_OUR)) == (SVpad_NAME|SVpad_OUR))
#define SvPAD_OUR_on(sv) (SvFLAGS(sv) |= SVpad_NAME|SVpad_OUR)
+#define OURSTASH(sv) (SvPAD_OUR(sv) ? GvSTASH(sv) : NULL)
+#define OURSTASH_set(sv, st) \
+ STMT_START { \
+ assert(SvTYPE(sv) == SVt_PVGV); \
+ GvSTASH(sv) = st; \
+ } STMT_END
+
#ifdef PERL_DEBUG_COW
#define SvRV(sv) (0 + (sv)->sv_u.svu_rv)
#else