summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-09 12:46:01 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-09 13:24:03 -0800
commit6b349a5c4c70a7c99eeaabacafc3ea993f2c7869 (patch)
tree6c873f46bdfbba9d2584bed44c217114ae36b54b
parent10cca365fcca0349c1d46c3a7ac05f425585739f (diff)
downloadperl-6b349a5c4c70a7c99eeaabacafc3ea993f2c7869.tar.gz
[perl #44895] += warning on uninit magic var
The only uses of USE_LEFT in core now occur when SvGETMAGIC has already been called. So returning true for magical SVs is not neces- sary. In fact, it was never correct. Also, the code in do_vop (which handles bitwise operations on strings) to avoid an uninitialized warning had the same buggy SvGMAGICAL check. Now, the warning from $uninit += 1 is suppressed for all undefined vars, not just amagical ones. This causes 6 to-do tests in assignwarn.t to pass.
-rw-r--r--doop.c2
-rw-r--r--pp.h2
-rw-r--r--t/op/assignwarn.t7
3 files changed, 5 insertions, 6 deletions
diff --git a/doop.c b/doop.c
index 231b3d86e0..f1304772c2 100644
--- a/doop.c
+++ b/doop.c
@@ -1014,7 +1014,7 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
PERL_ARGS_ASSERT_DO_VOP;
- if (sv != left || (optype != OP_BIT_AND && !SvOK(sv) && !SvGMAGICAL(sv)))
+ if (sv != left || (optype != OP_BIT_AND && !SvOK(sv)))
sv_setpvs(sv, ""); /* avoid undef warning on |= and ^= */
if (sv == left) {
lsave = lc = SvPV_force_nomg(left, leftlen);
diff --git a/pp.h b/pp.h
index aaadd404c7..63b22340f9 100644
--- a/pp.h
+++ b/pp.h
@@ -345,7 +345,7 @@ Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
#define dPOPXiirl(X) IV right = POPi; IV left = CAT2(X,i)
#define USE_LEFT(sv) \
- (SvOK(sv) || SvGMAGICAL(sv) || !(PL_op->op_flags & OPf_STACKED))
+ (SvOK(sv) || !(PL_op->op_flags & OPf_STACKED))
#define dPOPXiirl_ul_nomg(X) \
IV right = (sp--, SvIV_nomg(TOPp1s)); \
SV *leftsv = CAT2(X,s); \
diff --git a/t/op/assignwarn.t b/t/op/assignwarn.t
index 8d5487ac57..19b8e1de2c 100644
--- a/t/op/assignwarn.t
+++ b/t/op/assignwarn.t
@@ -19,11 +19,10 @@ my (%should_warn, %should_not);
++$should_warn{$_} foreach qw(* / x & ** << >>);
++$should_not{$_} foreach qw(+ - . | ^ && ||);
-my %todo_as_tie = reverse (add => '+', subtract => '-',
- bit_or => '|', bit_xor => '^');
+my %todo_as_tie;
-my %integer = reverse (i_add => '+', i_subtract => '-');
-$integer{$_} = 0 foreach qw(* / %);
+my %integer;
+$integer{$_} = 0 foreach qw(* / % + -);
sub TIESCALAR { my $x; bless \$x }
sub FETCH { ${$_[0]} }