From c475d5dcffe516f06f78424f9515dc90cebe2577 Mon Sep 17 00:00:00 2001 From: Gerard Goossen Date: Tue, 9 Aug 2011 20:52:34 +0200 Subject: [PATCH] Include name of global scalars in unitialized value warnings when the peephole optimiser isn't applied. When the peephole optimiser isn't applied warnings about uninitialised values from global scalars don't include the name of variable, because the OP_RV2SV + OP_GV isn't converted to OP_GVSV. This patch fixes that by extracting the name of the variable from the OP_RV2SV + OP_GV. --- sv.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sv.c b/sv.c index ed3e264..ea78558 100644 --- a/sv.c +++ b/sv.c @@ -13844,6 +13844,19 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv, keysv, index, subscript_type); } + case OP_RV2SV: + if (cUNOPx(obase)->op_first->op_type == OP_GV) { + /* $global */ + gv = cGVOPx_gv(cUNOPx(obase)->op_first); + if (!gv || !GvSTASH(gv)) + break; + if (match && (GvSV(gv) != uninit_sv)) + break; + return varname(gv, '$', 0, NULL, 0, FUV_SUBSCRIPT_NONE); + } + /* ${expr} */ + return find_uninit_var(cUNOPx(obase)->op_first, uninit_sv, 1); + case OP_PADSV: if (match && PAD_SVl(obase->op_targ) != uninit_sv) break; @@ -14024,7 +14037,6 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv, case OP_ENTEREVAL: /* could be eval $undef or $x='$undef'; eval $x */ - case OP_RV2SV: case OP_CUSTOM: /* XS or custom code could trigger random warnings */ /* the following ops are capable of returning PL_sv_undef even for -- 2.7.4