From: Gurusamy Sarathy Date: Thu, 27 Apr 2000 16:10:37 +0000 (+0000) Subject: avoid "will not stay shared" warnings for our variables (from X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=741b63383b6473fc5bf0b6dda1bdea3b4455a006;p=p5sagit%2Fp5-mst-13.2.git avoid "will not stay shared" warnings for our variables (from Robin Barker) p4raw-id: //depot/perl@5965 --- diff --git a/op.c b/op.c index 711be2f..7ca60ae 100644 --- a/op.c +++ b/op.c @@ -321,9 +321,12 @@ S_pad_findlex(pTHX_ char *name, PADOFFSET newoff, U32 seq, CV* startcv, } } else if (!CvUNIQUE(PL_compcv)) { - if (ckWARN(WARN_CLOSURE) && !SvFAKE(sv) && !CvUNIQUE(cv)) + if (ckWARN(WARN_CLOSURE) && !SvFAKE(sv) && !CvUNIQUE(cv) + && !(SvFLAGS(sv) & SVpad_OUR)) + { Perl_warner(aTHX_ WARN_CLOSURE, "Variable \"%s\" will not stay shared", name); + } } } av_store(PL_comppad, newoff, SvREFCNT_inc(oldsv)); diff --git a/t/pragma/warn/op b/t/pragma/warn/op index 1a79b4a..32f66dc 100644 --- a/t/pragma/warn/op +++ b/t/pragma/warn/op @@ -150,6 +150,17 @@ EXPECT # op.c use warnings 'closure' ; sub x { + our $x; + sub y { + $x + } + } +EXPECT + +######## +# op.c +use warnings 'closure' ; +sub x { my $x; sub y { sub { $x }