summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gv.c21
-rw-r--r--op.c26
-rw-r--r--toke.c4
3 files changed, 27 insertions, 24 deletions
diff --git a/gv.c b/gv.c
index c0c671d10b..128d790492 100644
--- a/gv.c
+++ b/gv.c
@@ -530,7 +530,9 @@ gv_fetchpv(char *nambeg, I32 add, I32 sv_type)
/* By this point we should have a stash and a name */
if (!stash) {
- if (add) {
+ if (!add)
+ return Nullgv;
+ if (add & ~2) {
char sv_type_char = ((sv_type == SVt_PV) ? '$'
: (sv_type == SVt_PVAV) ? '@'
: (sv_type == SVt_PVHV) ? '%'
@@ -539,16 +541,15 @@ gv_fetchpv(char *nambeg, I32 add, I32 sv_type)
warn("Global symbol \"%c%s\" requires explicit package name",
sv_type_char, name);
else
- warn("Global symbol \"%s\" requires explicit package name", name);
- ++error_count;
- stash = curstash ? curstash : defstash; /* avoid core dumps */
- add_gvflags = ((sv_type == SVt_PV) ? GVf_IMPORTED_SV
- : (sv_type == SVt_PVAV) ? GVf_IMPORTED_AV
- : (sv_type == SVt_PVHV) ? GVf_IMPORTED_HV
- : 0);
+ warn("Global symbol \"%s\" requires explicit package name",
+ name);
}
- else
- return Nullgv;
+ ++error_count;
+ stash = curstash ? curstash : defstash; /* avoid core dumps */
+ add_gvflags = ((sv_type == SVt_PV) ? GVf_IMPORTED_SV
+ : (sv_type == SVt_PVAV) ? GVf_IMPORTED_AV
+ : (sv_type == SVt_PVHV) ? GVf_IMPORTED_HV
+ : 0);
}
if (!SvREFCNT(stash)) /* symbol table under destruction */
diff --git a/op.c b/op.c
index fec670524a..b07c9ae310 100644
--- a/op.c
+++ b/op.c
@@ -3965,17 +3965,16 @@ ck_rvconst(register OP *o)
"Can't use bareword (\"%s\") as %s ref while \"strict refs\" in use",
name, badthing);
}
- kid->op_type = OP_GV;
+ /*
+ * This is a little tricky. We only want to add the symbol if we
+ * didn't add it in the lexer. Otherwise we get duplicate strict
+ * warnings. But if we didn't add it in the lexer, we must at
+ * least pretend like we wanted to add it even if it existed before,
+ * or we get possible typo warnings. OPpCONST_ENTERED says
+ * whether the lexer already added THIS instance of this symbol.
+ */
iscv = (o->op_type == OP_RV2CV) * 2;
- for (gv = 0; !gv; iscv++) {
- /*
- * This is a little tricky. We only want to add the symbol if we
- * didn't add it in the lexer. Otherwise we get duplicate strict
- * warnings. But if we didn't add it in the lexer, we must at
- * least pretend like we wanted to add it even if it existed before,
- * or we get possible typo warnings. OPpCONST_ENTERED says
- * whether the lexer already added THIS instance of this symbol.
- */
+ do {
gv = gv_fetchpv(name,
iscv | !(kid->op_private & OPpCONST_ENTERED),
iscv
@@ -3987,9 +3986,12 @@ ck_rvconst(register OP *o)
: o->op_type == OP_RV2HV
? SVt_PVHV
: SVt_PVGV);
+ } while (!gv && !(kid->op_private & OPpCONST_ENTERED) && !iscv++);
+ if (gv) {
+ kid->op_type = OP_GV;
+ SvREFCNT_dec(kid->op_sv);
+ kid->op_sv = SvREFCNT_inc(gv);
}
- SvREFCNT_dec(kid->op_sv);
- kid->op_sv = SvREFCNT_inc(gv);
}
return o;
}
diff --git a/toke.c b/toke.c
index ad423642a6..39382c9cf1 100644
--- a/toke.c
+++ b/toke.c
@@ -555,7 +555,7 @@ force_ident(register char *s, int kind)
/* XXX see note in pp_entereval() for why we forgo typo
warnings if the symbol must be introduced in an eval.
GSAR 96-10-12 */
- gv_fetchpv(s, in_eval ? GV_ADDMULTI : TRUE,
+ gv_fetchpv(s, in_eval ? (GV_ADDMULTI | 8) : TRUE,
kind == '$' ? SVt_PV :
kind == '@' ? SVt_PVAV :
kind == '%' ? SVt_PVHV :
@@ -1509,7 +1509,7 @@ yylex(void)
/* build ops for a bareword */
yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv(tokenbuf+1, 0));
yylval.opval->op_private = OPpCONST_ENTERED;
- gv_fetchpv(tokenbuf+1, in_eval ? GV_ADDMULTI : TRUE,
+ gv_fetchpv(tokenbuf+1, in_eval ? (GV_ADDMULTI | 8) : TRUE,
((tokenbuf[0] == '$') ? SVt_PV
: (tokenbuf[0] == '@') ? SVt_PVAV
: SVt_PVHV));