This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
avoid "will not stay shared" warnings for our variables (from
authorGurusamy Sarathy <gsar@cpan.org>
Thu, 27 Apr 2000 16:10:37 +0000 (16:10 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Thu, 27 Apr 2000 16:10:37 +0000 (16:10 +0000)
Robin Barker)

p4raw-id: //depot/perl@5965

op.c
t/pragma/warn/op

diff --git a/op.c b/op.c
index 711be2f..7ca60ae 100644 (file)
--- 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));
index 1a79b4a..32f66dc 100644 (file)
@@ -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 }