From: Dave Mitchell Date: Tue, 24 Jun 2008 13:30:23 +0000 (+0000) Subject: more incorrect variable reported in uninitialized value warnings X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fa8d1836673cdd4f08959b2dc7d9145ed5db7c50;p=p5sagit%2Fp5-mst-13.2.git more incorrect variable reported in uninitialized value warnings (the ones that change #34077 missed). It also degrades some print warnings - ie variable names no longer displayed. p4raw-link: @34077 on //depot/perl: 8b0dea507b8f946d8546917b8fda74bfbf233ac0 p4raw-id: //depot/perl@34084 --- diff --git a/sv.c b/sv.c index 37c60cf..6431cba 100644 --- a/sv.c +++ b/sv.c @@ -12585,6 +12585,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) case OP_PRTF: case OP_PRINT: case OP_SAY: + match = 1; /* print etc can return undef on defined args */ /* skip filehandle as it can't produce 'undef' warning */ o = cUNOPx(obase)->op_first; if ((obase->op_flags & OPf_STACKED) && o->op_type == OP_PUSHMARK) @@ -12662,6 +12663,12 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) case OP_SORT: case OP_CALLER: case OP_DOFILE: + case OP_PROTOTYPE: + case OP_NCMP: + case OP_SMARTMATCH: + case OP_UNPACK: + case OP_SYSOPEN: + case OP_SYSSEEK: match = 1; goto do_op; diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit index 2073f92..ba97f25 100644 --- a/t/lib/warnings/9uninit +++ b/t/lib/warnings/9uninit @@ -282,13 +282,13 @@ print STDERR $ga[1000]; print STDERR $m1, $g1, $ga[1],$m2; print STDERR "", $ga[1],""; EXPECT -Use of uninitialized value $ga[1000] in print at - line 5. -Use of uninitialized value $ga[1000] in print at - line 6. +Use of uninitialized value in print at - line 5. +Use of uninitialized value in print at - line 6. Use of uninitialized value $m1 in print at - line 7. Use of uninitialized value $g1 in print at - line 7. Use of uninitialized value in print at - line 7. Use of uninitialized value $m2 in print at - line 7. -Use of uninitialized value $ga[1] in print at - line 8. +Use of uninitialized value in print at - line 8. ######## use warnings 'uninitialized'; my ($m1); @@ -1166,15 +1166,15 @@ Use of uninitialized value $m2 in printf at - line 6. Use of uninitialized value $g1 in printf at - line 6. Use of uninitialized value $g2 in printf at - line 6. 0000 -Use of uninitialized value $ga[1000] in printf at - line 7. -Use of uninitialized value $ga[1000] in printf at - line 8. +Use of uninitialized value in printf at - line 7. +Use of uninitialized value in printf at - line 8. FOO1: Use of uninitialized value $m1 in printf at - line 9. Use of uninitialized value $g1 in printf at - line 9. Use of uninitialized value in printf at - line 9. Use of uninitialized value $m2 in printf at - line 9. FOO2: -Use of uninitialized value $ga[1] in printf at - line 10. +Use of uninitialized value in printf at - line 10. FOO3:XY ######## use warnings 'uninitialized'; @@ -1489,6 +1489,17 @@ $v = 1 + each %emptyh; $v = 1 + sort @emptya; my $zero = 0; $v = 1 + caller($zero); $v = 1 + do $nofile; +my $fn = sub {}; +$v = 1 + prototype $fn; +my $nan = "NaN"; +$v = 1 + ($nan <=> 1); +$v = 1 + ($fn ~~ 1); +$v = 1 + (print STDIN $f); # print to STDIN returns undef +$v = 1 + (printf STDIN "%s", $f); +{ use feature 'say'; $v = 1 + (say STDIN "%s", $f); } +$v = 1 + (unpack("",$f)); +$v = 1 + sysopen($f, $nofile, 0); +{ my $x = -1; $v = 1 + sysseek(STDIN, $x, 0); } EXPECT Use of uninitialized value in addition (+) at - line 8. @@ -1538,3 +1549,12 @@ Use of uninitialized value in addition (+) at - line 74. Use of uninitialized value in addition (+) at - line 75. Use of uninitialized value in addition (+) at - line 76. Use of uninitialized value in addition (+) at - line 77. +Use of uninitialized value in addition (+) at - line 79. +Use of uninitialized value in addition (+) at - line 81. +Use of uninitialized value in addition (+) at - line 82. +Use of uninitialized value in addition (+) at - line 83. +Use of uninitialized value in addition (+) at - line 84. +Use of uninitialized value in addition (+) at - line 85. +Use of uninitialized value in addition (+) at - line 86. +Use of uninitialized value in addition (+) at - line 87. +Use of uninitialized value in addition (+) at - line 88.