summaryrefslogtreecommitdiff
path: root/sv.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-12-12 21:31:10 +0000
committerNicholas Clark <nick@ccl4.org>2006-12-12 21:31:10 +0000
commita72e56b0b2a4a97735843f7586d49693804ee8a6 (patch)
treefd9288c05b4077d0450b24d84060ad041107262b /sv.h
parent85ffbbb0b9ce8124eef68c3c6234c26ffa9aba18 (diff)
downloadperl-a72e56b0b2a4a97735843f7586d49693804ee8a6.tar.gz
Assert that SvPAD_TYPED_on(), SvPAD_OUR_on() and SvPAD_STATE_on()
are never called on PVGVs. p4raw-id: //depot/perl@29537
Diffstat (limited to 'sv.h')
-rw-r--r--sv.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/sv.h b/sv.h
index 9d8ef39e60..0519db59f6 100644
--- a/sv.h
+++ b/sv.h
@@ -341,7 +341,7 @@ perform the upgrade if necessary. See C<svtype>.
/* PVHV */
#define SVphv_SHAREKEYS 0x20000000 /* PVHV
keys live on shared string table */
-/* PVNV, PVMG, PVGV, presumably only inside pads */
+/* PVNV, PVMG, presumably only inside pads */
#define SVpad_NAME 0x40000000 /* This SV is a name in the PAD, so
SVpad_TYPED, SVpad_OUR and
SVpad_STATE apply */
@@ -1098,15 +1098,34 @@ the scalar's value cannot change unless written to.
#define SvPAD_TYPED(sv) \
((SvFLAGS(sv) & (SVpad_NAME|SVpad_TYPED)) == (SVpad_NAME|SVpad_TYPED))
-#define SvPAD_TYPED_on(sv) (SvFLAGS(sv) |= SVpad_NAME|SVpad_TYPED)
#define SvPAD_OUR(sv) \
((SvFLAGS(sv) & (SVpad_NAME|SVpad_OUR)) == (SVpad_NAME|SVpad_OUR))
-#define SvPAD_OUR_on(sv) (SvFLAGS(sv) |= SVpad_NAME|SVpad_OUR)
#define SvPAD_STATE(sv) \
((SvFLAGS(sv) & (SVpad_NAME|SVpad_STATE)) == (SVpad_NAME|SVpad_STATE))
-#define SvPAD_STATE_on(sv) (SvFLAGS(sv) |= SVpad_NAME|SVpad_STATE)
+
+#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
+# define SvPAD_TYPED_on(sv) ({ \
+ SV *const whap = (SV *) (sv); \
+ assert(SvTYPE(whap) == SVt_PVMG); \
+ (SvFLAGS(whap) |= SVpad_NAME|SVpad_TYPED); \
+ })
+#define SvPAD_OUR_on(sv) ({ \
+ SV *const whap = (SV *) (sv); \
+ assert(SvTYPE(whap) == SVt_PVMG); \
+ (SvFLAGS(whap) |= SVpad_NAME|SVpad_OUR); \
+ })
+#define SvPAD_STATE_on(sv) ({ \
+ SV *const whap = (SV *) (sv); \
+ assert(SvTYPE(whap) == SVt_PVNV || SvTYPE(whap) == SVt_PVMG); \
+ (SvFLAGS(whap) |= SVpad_NAME|SVpad_STATE); \
+ })
+#else
+# define SvPAD_TYPED_on(sv) (SvFLAGS(sv) |= SVpad_NAME|SVpad_TYPED)
+# define SvPAD_OUR_on(sv) (SvFLAGS(sv) |= SVpad_NAME|SVpad_OUR)
+# define SvPAD_STATE_on(sv) (SvFLAGS(sv) |= SVpad_NAME|SVpad_STATE)
+#endif
#define OURSTASH(sv) \
(SvPAD_OUR(sv) ? ((XPVMG*) SvANY(sv))->xmg_u.xmg_ourstash : NULL)