summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embed.fnc3
-rw-r--r--embed.h2
-rw-r--r--op.c3
-rw-r--r--pad.c14
-rw-r--r--pad.h11
-rw-r--r--proto.h4
6 files changed, 31 insertions, 6 deletions
diff --git a/embed.fnc b/embed.fnc
index 440ada45b8..ef8cc8eea1 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1938,7 +1938,8 @@ pd |PADOFFSET|pad_add_name |NN const char *name\
: Only used in op.c
pd |PADOFFSET|pad_add_anon |NN SV* sv|OPCODE op_type
: Only used in op.c
-pd |void |pad_check_dup |NN const char* name|bool is_our|NN const HV* ourstash
+Mpd |void |pad_check_dup |NN const char *name|const STRLEN len\
+ |const U32 flags|NN const HV *ourstash
#ifdef DEBUGGING
: Only used PAD_SETSV() in op.c
pd |void |pad_setsv |PADOFFSET po|NN SV* sv
diff --git a/embed.h b/embed.h
index 99380961b1..95c93f4fd2 100644
--- a/embed.h
+++ b/embed.h
@@ -4089,7 +4089,7 @@
#define pad_undef(a) Perl_pad_undef(aTHX_ a)
#define pad_add_name(a,b,c,d,e) Perl_pad_add_name(aTHX_ a,b,c,d,e)
#define pad_add_anon(a,b) Perl_pad_add_anon(aTHX_ a,b)
-#define pad_check_dup(a,b,c) Perl_pad_check_dup(aTHX_ a,b,c)
+#define pad_check_dup(a,b,c,d) Perl_pad_check_dup(aTHX_ a,b,c,d)
#endif
#ifdef DEBUGGING
#ifdef PERL_CORE
diff --git a/op.c b/op.c
index b42bb5442a..aa5994dbcf 100644
--- a/op.c
+++ b/op.c
@@ -407,7 +407,8 @@ Perl_allocmy(pTHX_ const char *const name, const STRLEN len, const U32 flags)
}
/* check for duplicate declaration */
- pad_check_dup(name, is_our, (PL_curstash ? PL_curstash : PL_defstash));
+ pad_check_dup(name, len, is_our ? pad_add_OUR : 0,
+ (PL_curstash ? PL_curstash : PL_defstash));
/* allocate a spare slot and store the name in that slot */
diff --git a/pad.c b/pad.c
index becbdc91dd..e9c83fe619 100644
--- a/pad.c
+++ b/pad.c
@@ -540,15 +540,27 @@ C<is_our> indicates that the name to check is an 'our' declaration
/* XXX DAPM integrate this into pad_add_name ??? */
void
-Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash)
+Perl_pad_check_dup(pTHX_ const char *name, const STRLEN len, const U32 flags,
+ const HV *ourstash)
{
dVAR;
SV **svp;
PADOFFSET top, off;
+ const U32 is_our = flags & pad_add_OUR;
PERL_ARGS_ASSERT_PAD_CHECK_DUP;
ASSERT_CURPAD_ACTIVE("pad_check_dup");
+
+ if (flags & ~pad_add_OUR)
+ Perl_croak(aTHX_ "panic: pad_check_dup illegal flag bits 0x%" UVxf,
+ (UV)flags);
+
+ /* Until we're using the length for real, cross check that we're being told
+ the truth. */
+ PERL_UNUSED_ARG(len);
+ assert(strlen(name) == len);
+
if (AvFILLp(PL_comppad_name) < 0 || !ckWARN(WARN_MISC))
return; /* nothing to check */
diff --git a/pad.h b/pad.h
index 352a592f83..074d52ed21 100644
--- a/pad.h
+++ b/pad.h
@@ -112,6 +112,17 @@ typedef enum {
padtidy_FORMAT /* or a format */
} padtidy_type;
+#ifdef PERL_CORE
+
+/* flags for pad_add_name/pad_check_dup. SVf_UTF8 will also be valid in the
+ future. */
+
+# define pad_add_OUR 0x01 /* our declaration. */
+# define pad_add_STATE 0x02 /* state declaration. */
+# define pad_add_FAKE 0x04
+
+#endif
+
/* ASSERT_CURPAD_LEGAL and ASSERT_CURPAD_ACTIVE respectively determine
* whether PL_comppad and PL_curpad are consistent and whether they have
* active values */
diff --git a/proto.h b/proto.h
index 20f855177c..50f72a1d93 100644
--- a/proto.h
+++ b/proto.h
@@ -6111,9 +6111,9 @@ PERL_CALLCONV PADOFFSET Perl_pad_add_anon(pTHX_ SV* sv, OPCODE op_type)
#define PERL_ARGS_ASSERT_PAD_ADD_ANON \
assert(sv)
-PERL_CALLCONV void Perl_pad_check_dup(pTHX_ const char* name, bool is_our, const HV* ourstash)
+PERL_CALLCONV void Perl_pad_check_dup(pTHX_ const char *name, const STRLEN len, const U32 flags, const HV *ourstash)
__attribute__nonnull__(pTHX_1)
- __attribute__nonnull__(pTHX_3);
+ __attribute__nonnull__(pTHX_4);
#define PERL_ARGS_ASSERT_PAD_CHECK_DUP \
assert(name); assert(ourstash)