lexical warnings update (warning.t fails one test
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / op
index 7c2b6b8..dce52d8 100644 (file)
        defined %h ;
        my %h ; defined %h ;
 
+    Mandatory Warnings 
+    ------------------
+    Prototype mismatch:                [cv_ckproto]
+        sub fred() ;
+        sub fred($) {}
+
+    %s never introduced                [pad_leavemy]   TODO
+    Runaway prototype          [newSUB]        TODO
+    oops: oopsAV               [oopsAV]        TODO
+    oops: oopsHV               [oopsHV]        TODO
+    
+    
+
+
 __END__
 # op.c
 use warning 'unsafe' ;
 my $x ;
 my $x ;
+no warning 'unsafe' ;
+my $x ;
 EXPECT
 "my" variable $x masks earlier declaration in same scope at - line 4.
 ########
@@ -118,6 +134,17 @@ EXPECT
 Variable "$x" will not stay shared at - line 7.
 ########
 # op.c
+no warning 'unsafe' ;
+sub x {
+      my $x;
+      sub y {
+         $x
+      }
+   }
+EXPECT
+
+########
+# op.c
 use warning 'unsafe' ;
 sub x {
       my $x;
@@ -129,20 +156,37 @@ EXPECT
 Variable "$x" may be unavailable at - line 6.
 ########
 # op.c
+no warning 'unsafe' ;
+sub x {
+      my $x;
+      sub y {
+         sub { $x }
+      }
+   }
+EXPECT
+
+########
+# op.c
 use warning 'syntax' ;
 1 if $a = 1 ;
+no warning 'syntax' ;
+1 if $a = 1 ;
 EXPECT
 Found = in conditional, should be == at - line 3.
 ########
 # op.c
 use warning 'deprecated' ;
 split ;
+no warning 'deprecated' ;
+split ;
 EXPECT
 Use of implicit split to @_ is deprecated at - line 3.
 ########
 # op.c
 use warning 'deprecated' ;
 $a = split ;
+no warning 'deprecated' ;
+$a = split ;
 EXPECT
 Use of implicit split to @_ is deprecated at - line 3.
 ########
@@ -239,8 +283,65 @@ Useless use of getpwnam in void context at - line 52.
 Useless use of getpwuid in void context at - line 53.
 ########
 # op.c
+no warning 'void' ; close STDIN ;
+1 x 3 ;                        # OP_REPEAT
+                       # OP_GVSV
+wantarray ;            # OP_WANTARRAY
+                       # OP_GV
+                       # OP_PADSV
+                       # OP_PADAV
+                       # OP_PADHV
+                       # OP_PADANY
+                       # OP_AV2ARYLEN
+ref ;                  # OP_REF
+\@a ;                  # OP_REFGEN
+\$a ;                  # OP_SREFGEN
+defined $a ;           # OP_DEFINED
+hex $a ;               # OP_HEX
+oct $a ;               # OP_OCT
+length $a ;            # OP_LENGTH
+substr $a,1 ;          # OP_SUBSTR
+vec $a,1,2 ;           # OP_VEC
+index $a,1,2 ;         # OP_INDEX
+rindex $a,1,2 ;                # OP_RINDEX
+sprintf $a ;           # OP_SPRINTF
+$a[0] ;                        # OP_AELEM
+                       # OP_AELEMFAST
+@a[0] ;                        # OP_ASLICE
+#values %a ;           # OP_VALUES
+#keys %a ;             # OP_KEYS
+$a{0} ;                        # OP_HELEM
+@a{0} ;                        # OP_HSLICE
+unpack "a", "a" ;      # OP_UNPACK
+pack $a,"" ;           # OP_PACK
+join "" ;              # OP_JOIN
+(@a)[0,1] ;            # OP_LSLICE
+                       # OP_ANONLIST
+                       # OP_ANONHASH
+sort(1,2) ;            # OP_SORT
+reverse(1,2) ;         # OP_REVERSE
+                       # OP_RANGE
+                       # OP_FLIP
+(1 ..2) ;              # OP_FLOP
+caller ;               # OP_CALLER
+fileno STDIN ;         # OP_FILENO
+eof STDIN ;            # OP_EOF
+tell STDIN ;           # OP_TELL
+readlink 1;            # OP_READLINK
+time ;                 # OP_TIME
+localtime ;            # OP_LOCALTIME
+gmtime ;               # OP_GMTIME
+eval { getgrnam 1 };   # OP_GGRNAM
+eval { getgrgid 1 };   # OP_GGRGID
+eval { getpwnam 1 };   # OP_GPWNAM
+eval { getpwuid 1 };   # OP_GPWUID
+EXPECT
+########
+# op.c
 use warning 'void' ;
 for (@{[0]}) { "$_" }          # check warning isn't duplicated
+no warning 'void' ;
+for (@{[0]}) { "$_" }          # check warning isn't duplicated
 EXPECT
 Useless use of string in void context at - line 3.
 ########
@@ -257,6 +358,8 @@ EOM
     }
 }
 telldir 1 ;            # OP_TELLDIR
+no warning 'void' ;
+telldir 1 ;            # OP_TELLDIR
 EXPECT
 Useless use of telldir in void context at - line 13.
 ########
@@ -273,6 +376,8 @@ EOM
     }
 }
 getppid ;              # OP_GETPPID
+no warning 'void' ;
+getppid ;              # OP_GETPPID
 EXPECT
 Useless use of getppid in void context at - line 13.
 ########
@@ -289,6 +394,8 @@ EOM
     }
 }
 getpgrp ;              # OP_GETPGRP
+no warning 'void' ;
+getpgrp ;              # OP_GETPGRP
 EXPECT
 Useless use of getpgrp in void context at - line 13.
 ########
@@ -305,6 +412,8 @@ EOM
     }
 }
 times ;                        # OP_TMS
+no warning 'void' ;
+times ;                        # OP_TMS
 EXPECT
 Useless use of times in void context at - line 13.
 ########
@@ -321,6 +430,8 @@ EOM
     }
 }
 getpriority 1,2;       # OP_GETPRIORITY
+no warning 'void' ;
+getpriority 1,2;       # OP_GETPRIORITY
 EXPECT
 Useless use of getpriority in void context at - line 13.
 ########
@@ -337,6 +448,8 @@ EOM
     }
 }
 getlogin ;                     # OP_GETLOGIN
+no warning 'void' ;
+getlogin ;                     # OP_GETLOGIN
 EXPECT
 Useless use of getlogin in void context at - line 13.
 ########
@@ -377,6 +490,22 @@ getprotoent ;              # OP_GPROTOENT
 getservbyname 1,2;     # OP_GSBYNAME
 getservbyport 1,2;     # OP_GSBYPORT
 getservent ;           # OP_GSERVENT
+
+no warning 'void' ;
+getsockname STDIN ;    # OP_GETSOCKNAME
+getpeername STDIN ;    # OP_GETPEERNAME
+gethostbyname 1 ;      # OP_GHBYNAME
+gethostbyaddr 1,2;     # OP_GHBYADDR
+gethostent ;           # OP_GHOSTENT
+getnetbyname 1 ;       # OP_GNBYNAME
+getnetbyaddr 1,2 ;     # OP_GNBYADDR
+getnetent ;            # OP_GNETENT
+getprotobyname 1;      # OP_GPBYNAME
+getprotobynumber 1;    # OP_GPBYNUMBER
+getprotoent ;          # OP_GPROTOENT
+getservbyname 1,2;     # OP_GSBYNAME
+getservbyport 1,2;     # OP_GSBYPORT
+getservent ;           # OP_GSERVENT
 INIT {
    # some functions may not be there, so we exit without running
    exit;
@@ -403,6 +532,11 @@ use warning 'void' ;
 $a ; # OP_RV2SV
 @a ; # OP_RV2AV
 %a ; # OP_RV2HV
+no warning 'void' ;
+*a ; # OP_RV2GV
+$a ; # OP_RV2SV
+@a ; # OP_RV2AV
+%a ; # OP_RV2HV
 EXPECT
 Useless use of a variable in void context at - line 3.
 Useless use of a variable in void context at - line 4.
@@ -413,6 +547,9 @@ Useless use of a variable in void context at - line 6.
 use warning 'void' ;
 "abc"; # OP_CONST
 7 ; # OP_CONST
+no warning 'void' ;
+"abc"; # OP_CONST
+7 ; # OP_CONST
 EXPECT
 Useless use of a constant in void context at - line 3.
 Useless use of a constant in void context at - line 4.
@@ -432,6 +569,22 @@ my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
 %$c =~ /abc/ ;
 %$c =~ s/a/b/ ;
 %$c =~ tr/a/b/ ;
+{
+no warning 'unsafe' ;
+my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
+@a =~ /abc/ ;
+@a =~ s/a/b/ ;
+@a =~ tr/a/b/ ;
+@$b =~ /abc/ ;
+@$b =~ s/a/b/ ;
+@$b =~ tr/a/b/ ;
+%a =~ /abc/ ;
+%a =~ s/a/b/ ;
+%a =~ tr/a/b/ ;
+%$c =~ /abc/ ;
+%$c =~ s/a/b/ ;
+%$c =~ tr/a/b/ ;
+}
 EXPECT
 Applying pattern match to @array will act on scalar(@array) at - line 4.
 Applying substitution to @array will act on scalar(@array) at - line 5.
@@ -446,23 +599,29 @@ Applying character translation to %hash will act on scalar(%hash) at - line 12.
 Applying pattern match to %hash will act on scalar(%hash) at - line 13.
 Applying substitution to %hash will act on scalar(%hash) at - line 14.
 Applying character translation to %hash will act on scalar(%hash) at - line 15.
-Execution of - aborted due to compilation errors.
+BEGIN not safe after errors--compilation aborted at - line 17.
 ########
 # op.c
 use warning 'syntax' ;
 my $a, $b = (1,2);
+no warning 'syntax' ;
+my $c, $d = (1,2);
 EXPECT
 Parentheses missing around "my" list at - line 3.
 ########
 # op.c
 use warning 'syntax' ;
 local $a, $b = (1,2);
+no warning 'syntax' ;
+local $c, $d = (1,2);
 EXPECT
 Parentheses missing around "local" list at - line 3.
 ########
 # op.c
 use warning 'syntax' ;
 print (ABC || 1) ;
+no warning 'syntax' ;
+print (ABC || 1) ;
 EXPECT
 Probable precedence problem on logical or at - line 3.
 ########
@@ -473,6 +632,8 @@ Probable precedence problem on logical or at - line 3.
 use warning 'unsafe' ;
 open FH, "<abc" ;
 $x = 1 if $x = <FH> ;
+no warning 'unsafe' ;
+$x = 1 if $x = <FH> ;
 EXPECT
 Value of <HANDLE> construct can be "0"; test with defined() at - line 4.
 ########
@@ -480,6 +641,8 @@ Value of <HANDLE> construct can be "0"; test with defined() at - line 4.
 use warning 'unsafe' ;
 opendir FH, "." ;
 $x = 1 if $x = readdir FH ;
+no warning 'unsafe' ;
+$x = 1 if $x = readdir FH ;
 closedir FH ;
 EXPECT
 Value of readdir() operator can be "0"; test with defined() at - line 4.
@@ -487,6 +650,8 @@ Value of readdir() operator can be "0"; test with defined() at - line 4.
 # op.c
 use warning 'unsafe' ;
 $x = 1 if $x = <*> ;
+no warning 'unsafe' ;
+$x = 1 if $x = <*> ;
 EXPECT
 Value of glob construct can be "0"; test with defined() at - line 3.
 ########
@@ -494,12 +659,16 @@ Value of glob construct can be "0"; test with defined() at - line 3.
 use warning 'unsafe' ;
 %a = (1,2,3,4) ;
 $x = 1 if $x = each %a ;
+no warning 'unsafe' ;
+$x = 1 if $x = each %a ;
 EXPECT
 Value of each() operator can be "0"; test with defined() at - line 4.
 ########
 # op.c
 use warning 'unsafe' ;
 $x = 1 while $x = <*> and 0 ;
+no warning 'unsafe' ;
+$x = 1 while $x = <*> and 0 ;
 EXPECT
 Value of glob construct can be "0"; test with defined() at - line 3.
 ########
@@ -507,6 +676,8 @@ Value of glob construct can be "0"; test with defined() at - line 3.
 use warning 'unsafe' ;
 opendir FH, "." ;
 $x = 1 while $x = readdir FH and 0 ;
+no warning 'unsafe' ;
+$x = 1 while $x = readdir FH and 0 ;
 closedir FH ;
 EXPECT
 Value of readdir() operator can be "0"; test with defined() at - line 4.
@@ -515,6 +686,8 @@ Value of readdir() operator can be "0"; test with defined() at - line 4.
 use warning 'redefine' ;
 sub fred {}
 sub fred {}
+no warning 'redefine' ;
+sub fred {}
 EXPECT
 Subroutine fred redefined at - line 4.
 ########
@@ -522,6 +695,8 @@ Subroutine fred redefined at - line 4.
 use warning 'redefine' ;
 sub fred () { 1 }
 sub fred () { 1 }
+no warning 'redefine' ;
+sub fred () { 1 }
 EXPECT
 Constant subroutine fred redefined at - line 4.
 ########
@@ -531,18 +706,25 @@ format FRED =
 .
 format FRED =
 .
+no warning 'redefine' ;
+format FRED =
+.
 EXPECT
 Format FRED redefined at - line 5.
 ########
 # op.c
 use warning 'syntax' ;
 push FRED;
+no warning 'syntax' ;
+push FRED;
 EXPECT
 Array @FRED missing the @ in argument 1 of push() at - line 3.
 ########
 # op.c
 use warning 'syntax' ;
 @a = keys FRED ;
+no warning 'syntax' ;
+@a = keys FRED ;
 EXPECT
 Hash %FRED missing the % in argument 1 of keys() at - line 3.
 ########
@@ -588,3 +770,35 @@ my %h; defined(%h);
 EXPECT
 defined(%hash) is deprecated at - line 3.
 (Maybe you should just omit the defined()?)
+########
+# op.c
+no warning 'syntax' ;
+exec "$^X -e 1" ; 
+my $a
+EXPECT
+
+########
+# op.c
+sub fred();
+sub fred($) {}
+EXPECT
+Prototype mismatch: sub main::fred () vs ($) at - line 3.
+########
+# op.c
+$^W = 0 ;
+sub fred() ;
+sub fred($) {}
+{
+    no warning 'unsafe' ;
+    sub Fred() ;
+    sub Fred($) {}
+    use warning 'unsafe' ;
+    sub freD() ;
+    sub freD($) {}
+}
+sub FRED() ;
+sub FRED($) {}
+EXPECT
+Prototype mismatch: sub main::fred () vs ($) at - line 4.
+Prototype mismatch: sub main::freD () vs ($) at - line 11.
+Prototype mismatch: sub main::FRED () vs ($) at - line 14.