Add a new warning, "Possible precedence problem on bitwise
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / op
1   op.c          AOK
2
3      "my" variable %s masks earlier declaration in same scope
4         my $x;
5         my $x ;
6
7      Variable "%s" may be unavailable 
8         sub x {
9             my $x;
10             sub y {
11                 $x
12             }
13         }
14
15      Variable "%s" will not stay shared 
16         sub x {
17             my $x;
18             sub y {
19                 sub { $x }
20             }
21         }
22
23      Found = in conditional, should be ==
24         1 if $a = 1 ;
25
26      Use of implicit split to @_ is deprecated
27         split ;
28
29      Use of implicit split to @_ is deprecated
30         $a = split ;
31
32      Useless use of time in void context
33      Useless use of a variable in void context
34      Useless use of a constant in void context
35         time ;
36         $a ;
37         "abc"
38
39      Useless use of sort in scalar context
40         my $x = sort (2,1,3);
41
42      Applying %s to %s will act on scalar(%s)
43         my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
44         @a =~ /abc/ ;
45         @a =~ s/a/b/ ;
46         @a =~ tr/a/b/ ;
47         @$b =~ /abc/ ;
48         @$b =~ s/a/b/ ;
49         @$b =~ tr/a/b/ ;
50         %a =~ /abc/ ;
51         %a =~ s/a/b/ ;
52         %a =~ tr/a/b/ ;
53         %$c =~ /abc/ ;
54         %$c =~ s/a/b/ ;
55         %$c =~ tr/a/b/ ;
56
57
58      Parentheses missing around "my" list at -e line 1.
59        my $a, $b = (1,2);
60  
61      Parentheses missing around "local" list at -e line 1.
62        local $a, $b = (1,2);
63  
64      Bareword found in conditional at -e line 1.
65        use warnings 'bareword'; my $x = print(ABC || 1);
66  
67      Value of %s may be \"0\"; use \"defined\" 
68         $x = 1 if $x = <FH> ;
69         $x = 1 while $x = <FH> ;
70
71      Subroutine fred redefined at -e line 1.
72        sub fred{1;} sub fred{1;}
73  
74      Constant subroutine %s redefined 
75         sub fred() {1;} sub fred() {1;}
76  
77      Format FRED redefined at /tmp/x line 5.
78        format FRED =
79        .
80        format FRED =
81        .
82  
83      Array @%s missing the @ in argument %d of %s() 
84         push fred ;
85  
86      Hash %%%s missing the %% in argument %d of %s() 
87         keys joe ;
88  
89      Statement unlikely to be reached
90         (Maybe you meant system() when you said exec()?
91         exec "true" ; my $a
92
93      defined(@array) is deprecated
94         (Maybe you should just omit the defined()?)
95         my @a ; defined @a ;
96         defined (@a = (1,2,3)) ;
97
98      defined(%hash) is deprecated
99         (Maybe you should just omit the defined()?)
100         my %h ; defined %h ;
101     
102      /---/ should probably be written as "---"
103         join(/---/, @foo);
104
105     %s() called too early to check prototype            [Perl_peep]
106         fred() ; sub fred ($$) {}
107
108
109     Package `%s' not found (did you use the incorrect case?)
110
111     Use of /g modifier is meaningless in split
112
113     Possible precedence problem on bitwise %c operator  [Perl_ck_bitop]
114
115     Mandatory Warnings 
116     ------------------
117     Prototype mismatch:         [cv_ckproto]
118         sub fred() ;
119         sub fred($) {}
120
121     %s never introduced         [pad_leavemy]   TODO
122     Runaway prototype           [newSUB]        TODO
123     oops: oopsAV                [oopsAV]        TODO
124     oops: oopsHV                [oopsHV]        TODO
125     
126 __END__
127 # op.c
128 use warnings 'misc' ;
129 my $x ;
130 my $x ;
131 my $y = my $y ;
132 no warnings 'misc' ;
133 my $x ;
134 my $y ;
135 EXPECT
136 "my" variable $x masks earlier declaration in same scope at - line 4.
137 "my" variable $y masks earlier declaration in same statement at - line 5.
138 ########
139 # op.c
140 use warnings 'closure' ;
141 sub x {
142       my $x;
143       sub y {
144          $x
145       }
146    }
147 EXPECT
148 Variable "$x" will not stay shared at - line 7.
149 ########
150 # op.c
151 no warnings 'closure' ;
152 sub x {
153       my $x;
154       sub y {
155          $x
156       }
157    }
158 EXPECT
159
160 ########
161 # op.c
162 use warnings 'closure' ;
163 sub x {
164       our $x;
165       sub y {
166          $x
167       }
168    }
169 EXPECT
170
171 ########
172 # op.c
173 use warnings 'closure' ;
174 sub x {
175       my $x;
176       sub y {
177          sub { $x }
178       }
179    }
180 EXPECT
181 Variable "$x" may be unavailable at - line 6.
182 ########
183 # op.c
184 no warnings 'closure' ;
185 sub x {
186       my $x;
187       sub y {
188          sub { $x }
189       }
190    }
191 EXPECT
192
193 ########
194 # op.c
195 use warnings 'syntax' ;
196 1 if $a = 1 ;
197 no warnings 'syntax' ;
198 1 if $a = 1 ;
199 EXPECT
200 Found = in conditional, should be == at - line 3.
201 ########
202 # op.c
203 use warnings 'deprecated' ;
204 split ;
205 no warnings 'deprecated' ;
206 split ;
207 EXPECT
208 Use of implicit split to @_ is deprecated at - line 3.
209 ########
210 # op.c
211 use warnings 'deprecated' ;
212 $a = split ;
213 no warnings 'deprecated' ;
214 $a = split ;
215 EXPECT
216 Use of implicit split to @_ is deprecated at - line 3.
217 ########
218 # op.c
219 use warnings 'deprecated';
220 my (@foo, %foo);
221 %main::foo->{"bar"};
222 %foo->{"bar"};
223 @main::foo->[23];
224 @foo->[23];
225 $main::foo = {}; %$main::foo->{"bar"};
226 $foo = {}; %$foo->{"bar"};
227 $main::foo = []; @$main::foo->[34];
228 $foo = []; @$foo->[34];
229 no warnings 'deprecated';
230 %main::foo->{"bar"};
231 %foo->{"bar"};
232 @main::foo->[23];
233 @foo->[23];
234 $main::foo = {}; %$main::foo->{"bar"};
235 $foo = {}; %$foo->{"bar"};
236 $main::foo = []; @$main::foo->[34];
237 $foo = []; @$foo->[34];
238 EXPECT
239 Using a hash as a reference is deprecated at - line 4.
240 Using a hash as a reference is deprecated at - line 5.
241 Using an array as a reference is deprecated at - line 6.
242 Using an array as a reference is deprecated at - line 7.
243 Using a hash as a reference is deprecated at - line 8.
244 Using a hash as a reference is deprecated at - line 9.
245 Using an array as a reference is deprecated at - line 10.
246 Using an array as a reference is deprecated at - line 11.
247 ########
248 # op.c
249 use warnings 'void' ; close STDIN ;
250 1 x 3 ;                 # OP_REPEAT
251                         # OP_GVSV
252 wantarray ;             # OP_WANTARRAY
253                         # OP_GV
254                         # OP_PADSV
255                         # OP_PADAV
256                         # OP_PADHV
257                         # OP_PADANY
258                         # OP_AV2ARYLEN
259 ref ;                   # OP_REF
260 \@a ;                   # OP_REFGEN
261 \$a ;                   # OP_SREFGEN
262 defined $a ;            # OP_DEFINED
263 hex $a ;                # OP_HEX
264 oct $a ;                # OP_OCT
265 length $a ;             # OP_LENGTH
266 substr $a,1 ;           # OP_SUBSTR
267 vec $a,1,2 ;            # OP_VEC
268 index $a,1,2 ;          # OP_INDEX
269 rindex $a,1,2 ;         # OP_RINDEX
270 sprintf $a ;            # OP_SPRINTF
271 $a[0] ;                 # OP_AELEM
272                         # OP_AELEMFAST
273 @a[0] ;                 # OP_ASLICE
274 #values %a ;            # OP_VALUES
275 #keys %a ;              # OP_KEYS
276 $a{0} ;                 # OP_HELEM
277 @a{0} ;                 # OP_HSLICE
278 unpack "a", "a" ;       # OP_UNPACK
279 pack $a,"" ;            # OP_PACK
280 join "" ;               # OP_JOIN
281 (@a)[0,1] ;             # OP_LSLICE
282                         # OP_ANONLIST
283                         # OP_ANONHASH
284 sort(1,2) ;             # OP_SORT
285 reverse(1,2) ;          # OP_REVERSE
286                         # OP_RANGE
287                         # OP_FLIP
288 (1 ..2) ;               # OP_FLOP
289 caller ;                # OP_CALLER
290 fileno STDIN ;          # OP_FILENO
291 eof STDIN ;             # OP_EOF
292 tell STDIN ;            # OP_TELL
293 readlink 1;             # OP_READLINK
294 time ;                  # OP_TIME
295 localtime ;             # OP_LOCALTIME
296 gmtime ;                # OP_GMTIME
297 eval { getgrnam 1 };    # OP_GGRNAM
298 eval { getgrgid 1 };    # OP_GGRGID
299 eval { getpwnam 1 };    # OP_GPWNAM
300 eval { getpwuid 1 };    # OP_GPWUID
301 EXPECT
302 Useless use of repeat (x) in void context at - line 3.
303 Useless use of wantarray in void context at - line 5.
304 Useless use of reference-type operator in void context at - line 12.
305 Useless use of reference constructor in void context at - line 13.
306 Useless use of single ref constructor in void context at - line 14.
307 Useless use of defined operator in void context at - line 15.
308 Useless use of hex in void context at - line 16.
309 Useless use of oct in void context at - line 17.
310 Useless use of length in void context at - line 18.
311 Useless use of substr in void context at - line 19.
312 Useless use of vec in void context at - line 20.
313 Useless use of index in void context at - line 21.
314 Useless use of rindex in void context at - line 22.
315 Useless use of sprintf in void context at - line 23.
316 Useless use of array element in void context at - line 24.
317 Useless use of array slice in void context at - line 26.
318 Useless use of hash element in void context at - line 29.
319 Useless use of hash slice in void context at - line 30.
320 Useless use of unpack in void context at - line 31.
321 Useless use of pack in void context at - line 32.
322 Useless use of join or string in void context at - line 33.
323 Useless use of list slice in void context at - line 34.
324 Useless use of sort in void context at - line 37.
325 Useless use of reverse in void context at - line 38.
326 Useless use of range (or flop) in void context at - line 41.
327 Useless use of caller in void context at - line 42.
328 Useless use of fileno in void context at - line 43.
329 Useless use of eof in void context at - line 44.
330 Useless use of tell in void context at - line 45.
331 Useless use of readlink in void context at - line 46.
332 Useless use of time in void context at - line 47.
333 Useless use of localtime in void context at - line 48.
334 Useless use of gmtime in void context at - line 49.
335 Useless use of getgrnam in void context at - line 50.
336 Useless use of getgrgid in void context at - line 51.
337 Useless use of getpwnam in void context at - line 52.
338 Useless use of getpwuid in void context at - line 53.
339 ########
340 # op.c
341 use warnings 'void' ; close STDIN ;
342 my $x = sort (2,1,3);
343 no warnings 'void' ;
344 $x = sort (2,1,3);
345 EXPECT
346 Useless use of sort in scalar context at - line 3.
347 ########
348 # op.c
349 no warnings 'void' ; close STDIN ;
350 1 x 3 ;                 # OP_REPEAT
351                         # OP_GVSV
352 wantarray ;             # OP_WANTARRAY
353                         # OP_GV
354                         # OP_PADSV
355                         # OP_PADAV
356                         # OP_PADHV
357                         # OP_PADANY
358                         # OP_AV2ARYLEN
359 ref ;                   # OP_REF
360 \@a ;                   # OP_REFGEN
361 \$a ;                   # OP_SREFGEN
362 defined $a ;            # OP_DEFINED
363 hex $a ;                # OP_HEX
364 oct $a ;                # OP_OCT
365 length $a ;             # OP_LENGTH
366 substr $a,1 ;           # OP_SUBSTR
367 vec $a,1,2 ;            # OP_VEC
368 index $a,1,2 ;          # OP_INDEX
369 rindex $a,1,2 ;         # OP_RINDEX
370 sprintf $a ;            # OP_SPRINTF
371 $a[0] ;                 # OP_AELEM
372                         # OP_AELEMFAST
373 @a[0] ;                 # OP_ASLICE
374 #values %a ;            # OP_VALUES
375 #keys %a ;              # OP_KEYS
376 $a{0} ;                 # OP_HELEM
377 @a{0} ;                 # OP_HSLICE
378 unpack "a", "a" ;       # OP_UNPACK
379 pack $a,"" ;            # OP_PACK
380 join "" ;               # OP_JOIN
381 (@a)[0,1] ;             # OP_LSLICE
382                         # OP_ANONLIST
383                         # OP_ANONHASH
384 sort(1,2) ;             # OP_SORT
385 reverse(1,2) ;          # OP_REVERSE
386                         # OP_RANGE
387                         # OP_FLIP
388 (1 ..2) ;               # OP_FLOP
389 caller ;                # OP_CALLER
390 fileno STDIN ;          # OP_FILENO
391 eof STDIN ;             # OP_EOF
392 tell STDIN ;            # OP_TELL
393 readlink 1;             # OP_READLINK
394 time ;                  # OP_TIME
395 localtime ;             # OP_LOCALTIME
396 gmtime ;                # OP_GMTIME
397 eval { getgrnam 1 };    # OP_GGRNAM
398 eval { getgrgid 1 };    # OP_GGRGID
399 eval { getpwnam 1 };    # OP_GPWNAM
400 eval { getpwuid 1 };    # OP_GPWUID
401 EXPECT
402 ########
403 # op.c
404 use warnings 'void' ;
405 for (@{[0]}) { "$_" }           # check warning isn't duplicated
406 no warnings 'void' ;
407 for (@{[0]}) { "$_" }           # check warning isn't duplicated
408 EXPECT
409 Useless use of string in void context at - line 3.
410 ########
411 # op.c
412 use warnings 'void' ;
413 use Config ;
414 BEGIN {
415     if ( ! $Config{d_telldir}) {
416         print <<EOM ;
417 SKIPPED
418 # telldir not present
419 EOM
420         exit 
421     }
422 }
423 telldir 1 ;             # OP_TELLDIR
424 no warnings 'void' ;
425 telldir 1 ;             # OP_TELLDIR
426 EXPECT
427 Useless use of telldir in void context at - line 13.
428 ########
429 # op.c
430 use warnings 'void' ;
431 use Config ;
432 BEGIN {
433     if ( ! $Config{d_getppid}) {
434         print <<EOM ;
435 SKIPPED
436 # getppid not present
437 EOM
438         exit 
439     }
440 }
441 getppid ;               # OP_GETPPID
442 no warnings 'void' ;
443 getppid ;               # OP_GETPPID
444 EXPECT
445 Useless use of getppid in void context at - line 13.
446 ########
447 # op.c
448 use warnings 'void' ;
449 use Config ;
450 BEGIN {
451     if ( ! $Config{d_getpgrp}) {
452         print <<EOM ;
453 SKIPPED
454 # getpgrp not present
455 EOM
456         exit 
457     }
458 }
459 getpgrp ;               # OP_GETPGRP
460 no warnings 'void' ;
461 getpgrp ;               # OP_GETPGRP
462 EXPECT
463 Useless use of getpgrp in void context at - line 13.
464 ########
465 # op.c
466 use warnings 'void' ;
467 use Config ;
468 BEGIN {
469     if ( ! $Config{d_times}) {
470         print <<EOM ;
471 SKIPPED
472 # times not present
473 EOM
474         exit 
475     }
476 }
477 times ;                 # OP_TMS
478 no warnings 'void' ;
479 times ;                 # OP_TMS
480 EXPECT
481 Useless use of times in void context at - line 13.
482 ########
483 # op.c
484 use warnings 'void' ;
485 use Config ;
486 BEGIN {
487     if ( ! $Config{d_getprior} or $^O eq 'os2') { # Locks before fixpak22
488         print <<EOM ;
489 SKIPPED
490 # getpriority not present
491 EOM
492         exit 
493     }
494 }
495 getpriority 1,2;        # OP_GETPRIORITY
496 no warnings 'void' ;
497 getpriority 1,2;        # OP_GETPRIORITY
498 EXPECT
499 Useless use of getpriority in void context at - line 13.
500 ########
501 # op.c
502 use warnings 'void' ;
503 use Config ;
504 BEGIN {
505     if ( ! $Config{d_getlogin}) {
506         print <<EOM ;
507 SKIPPED
508 # getlogin not present
509 EOM
510         exit 
511     }
512 }
513 getlogin ;                      # OP_GETLOGIN
514 no warnings 'void' ;
515 getlogin ;                      # OP_GETLOGIN
516 EXPECT
517 Useless use of getlogin in void context at - line 13.
518 ########
519 # op.c
520 use warnings 'void' ;
521 use Config ; BEGIN {
522 if ( ! $Config{d_socket}) {
523     print <<EOM ;
524 SKIPPED
525 # getsockname not present
526 # getpeername not present
527 # gethostbyname not present
528 # gethostbyaddr not present
529 # gethostent not present
530 # getnetbyname not present
531 # getnetbyaddr not present
532 # getnetent not present
533 # getprotobyname not present
534 # getprotobynumber not present
535 # getprotoent not present
536 # getservbyname not present
537 # getservbyport not present
538 # getservent not present
539 EOM
540     exit 
541 } }
542 getsockname STDIN ;     # OP_GETSOCKNAME
543 getpeername STDIN ;     # OP_GETPEERNAME
544 gethostbyname 1 ;       # OP_GHBYNAME
545 gethostbyaddr 1,2;      # OP_GHBYADDR
546 gethostent ;            # OP_GHOSTENT
547 getnetbyname 1 ;        # OP_GNBYNAME
548 getnetbyaddr 1,2 ;      # OP_GNBYADDR
549 getnetent ;             # OP_GNETENT
550 getprotobyname 1;       # OP_GPBYNAME
551 getprotobynumber 1;     # OP_GPBYNUMBER
552 getprotoent ;           # OP_GPROTOENT
553 getservbyname 1,2;      # OP_GSBYNAME
554 getservbyport 1,2;      # OP_GSBYPORT
555 getservent ;            # OP_GSERVENT
556
557 no warnings 'void' ;
558 getsockname STDIN ;     # OP_GETSOCKNAME
559 getpeername STDIN ;     # OP_GETPEERNAME
560 gethostbyname 1 ;       # OP_GHBYNAME
561 gethostbyaddr 1,2;      # OP_GHBYADDR
562 gethostent ;            # OP_GHOSTENT
563 getnetbyname 1 ;        # OP_GNBYNAME
564 getnetbyaddr 1,2 ;      # OP_GNBYADDR
565 getnetent ;             # OP_GNETENT
566 getprotobyname 1;       # OP_GPBYNAME
567 getprotobynumber 1;     # OP_GPBYNUMBER
568 getprotoent ;           # OP_GPROTOENT
569 getservbyname 1,2;      # OP_GSBYNAME
570 getservbyport 1,2;      # OP_GSBYPORT
571 getservent ;            # OP_GSERVENT
572 INIT {
573    # some functions may not be there, so we exit without running
574    exit;
575 }
576 EXPECT
577 Useless use of getsockname in void context at - line 24.
578 Useless use of getpeername in void context at - line 25.
579 Useless use of gethostbyname in void context at - line 26.
580 Useless use of gethostbyaddr in void context at - line 27.
581 Useless use of gethostent in void context at - line 28.
582 Useless use of getnetbyname in void context at - line 29.
583 Useless use of getnetbyaddr in void context at - line 30.
584 Useless use of getnetent in void context at - line 31.
585 Useless use of getprotobyname in void context at - line 32.
586 Useless use of getprotobynumber in void context at - line 33.
587 Useless use of getprotoent in void context at - line 34.
588 Useless use of getservbyname in void context at - line 35.
589 Useless use of getservbyport in void context at - line 36.
590 Useless use of getservent in void context at - line 37.
591 ########
592 # op.c
593 use warnings 'void' ;
594 *a ; # OP_RV2GV
595 $a ; # OP_RV2SV
596 @a ; # OP_RV2AV
597 %a ; # OP_RV2HV
598 no warnings 'void' ;
599 *a ; # OP_RV2GV
600 $a ; # OP_RV2SV
601 @a ; # OP_RV2AV
602 %a ; # OP_RV2HV
603 EXPECT
604 Useless use of a variable in void context at - line 3.
605 Useless use of a variable in void context at - line 4.
606 Useless use of a variable in void context at - line 5.
607 Useless use of a variable in void context at - line 6.
608 ########
609 # op.c
610 use warnings 'void' ;
611 "abc"; # OP_CONST
612 7 ; # OP_CONST
613 no warnings 'void' ;
614 "abc"; # OP_CONST
615 7 ; # OP_CONST
616 EXPECT
617 Useless use of a constant in void context at - line 3.
618 Useless use of a constant in void context at - line 4.
619 ########
620 # op.c
621 #
622 use warnings 'misc' ;
623 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
624 @a =~ /abc/ ;
625 @a =~ s/a/b/ ;
626 @a =~ tr/a/b/ ;
627 @$b =~ /abc/ ;
628 @$b =~ s/a/b/ ;
629 @$b =~ tr/a/b/ ;
630 %a =~ /abc/ ;
631 %a =~ s/a/b/ ;
632 %a =~ tr/a/b/ ;
633 %$c =~ /abc/ ;
634 %$c =~ s/a/b/ ;
635 %$c =~ tr/a/b/ ;
636 {
637 no warnings 'misc' ;
638 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
639 @a =~ /abc/ ;
640 @a =~ s/a/b/ ;
641 @a =~ tr/a/b/ ;
642 @$b =~ /abc/ ;
643 @$b =~ s/a/b/ ;
644 @$b =~ tr/a/b/ ;
645 %a =~ /abc/ ;
646 %a =~ s/a/b/ ;
647 %a =~ tr/a/b/ ;
648 %$c =~ /abc/ ;
649 %$c =~ s/a/b/ ;
650 %$c =~ tr/a/b/ ;
651 }
652 EXPECT
653 Applying pattern match (m//) to @array will act on scalar(@array) at - line 5.
654 Applying substitution (s///) to @array will act on scalar(@array) at - line 6.
655 Applying transliteration (tr///) to @array will act on scalar(@array) at - line 7.
656 Applying pattern match (m//) to @array will act on scalar(@array) at - line 8.
657 Applying substitution (s///) to @array will act on scalar(@array) at - line 9.
658 Applying transliteration (tr///) to @array will act on scalar(@array) at - line 10.
659 Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 11.
660 Applying substitution (s///) to %hash will act on scalar(%hash) at - line 12.
661 Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 13.
662 Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 14.
663 Applying substitution (s///) to %hash will act on scalar(%hash) at - line 15.
664 Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 16.
665 Can't modify private array in substitution (s///) at - line 6, near "s/a/b/ ;"
666 BEGIN not safe after errors--compilation aborted at - line 18.
667 ########
668 # op.c
669 use warnings 'syntax' ;
670 my $a, $b = (1,2);
671 no warnings 'syntax' ;
672 my $c, $d = (1,2);
673 EXPECT
674 Parentheses missing around "my" list at - line 3.
675 ########
676 # op.c
677 use warnings 'syntax' ;
678 local $a, $b = (1,2);
679 no warnings 'syntax' ;
680 local $c, $d = (1,2);
681 EXPECT
682 Parentheses missing around "local" list at - line 3.
683 ########
684 # op.c
685 use warnings 'bareword' ;
686 print (ABC || 1) ;
687 no warnings 'bareword' ;
688 print (ABC || 1) ;
689 EXPECT
690 Bareword found in conditional at - line 3.
691 ########
692 --FILE-- abc
693
694 --FILE--
695 # op.c
696 use warnings 'misc' ;
697 open FH, "<abc" ;
698 $x = 1 if $x = <FH> ;
699 no warnings 'misc' ;
700 $x = 1 if $x = <FH> ;
701 EXPECT
702 Value of <HANDLE> construct can be "0"; test with defined() at - line 4.
703 ########
704 # op.c
705 use warnings 'misc' ;
706 opendir FH, "." ;
707 $x = 1 if $x = readdir FH ;
708 no warnings 'misc' ;
709 $x = 1 if $x = readdir FH ;
710 closedir FH ;
711 EXPECT
712 Value of readdir() operator can be "0"; test with defined() at - line 4.
713 ########
714 # op.c
715 use warnings 'misc' ;
716 $x = 1 if $x = <*> ;
717 no warnings 'misc' ;
718 $x = 1 if $x = <*> ;
719 EXPECT
720 Value of glob construct can be "0"; test with defined() at - line 3.
721 ########
722 # op.c
723 use warnings 'misc' ;
724 %a = (1,2,3,4) ;
725 $x = 1 if $x = each %a ;
726 no warnings 'misc' ;
727 $x = 1 if $x = each %a ;
728 EXPECT
729 Value of each() operator can be "0"; test with defined() at - line 4.
730 ########
731 # op.c
732 use warnings 'misc' ;
733 $x = 1 while $x = <*> and 0 ;
734 no warnings 'misc' ;
735 $x = 1 while $x = <*> and 0 ;
736 EXPECT
737 Value of glob construct can be "0"; test with defined() at - line 3.
738 ########
739 # op.c
740 use warnings 'misc' ;
741 opendir FH, "." ;
742 $x = 1 while $x = readdir FH and 0 ;
743 no warnings 'misc' ;
744 $x = 1 while $x = readdir FH and 0 ;
745 closedir FH ;
746 EXPECT
747 Value of readdir() operator can be "0"; test with defined() at - line 4.
748 ########
749 # op.c
750 use warnings 'redefine' ;
751 sub fred {}
752 sub fred {}
753 no warnings 'redefine' ;
754 sub fred {}
755 EXPECT
756 Subroutine fred redefined at - line 4.
757 ########
758 # op.c
759 use warnings 'redefine' ;
760 sub fred () { 1 }
761 sub fred () { 1 }
762 no warnings 'redefine' ;
763 sub fred () { 1 }
764 EXPECT
765 Constant subroutine fred redefined at - line 4.
766 ########
767 # op.c
768 no warnings 'redefine' ;
769 sub fred () { 1 }
770 sub fred () { 2 }
771 EXPECT
772 Constant subroutine fred redefined at - line 4.
773 ########
774 # op.c
775 no warnings 'redefine' ;
776 sub fred () { 1 }
777 *fred = sub () { 2 };
778 EXPECT
779 Constant subroutine main::fred redefined at - line 4.
780 ########
781 # op.c
782 use warnings 'redefine' ;
783 format FRED =
784 .
785 format FRED =
786 .
787 no warnings 'redefine' ;
788 format FRED =
789 .
790 EXPECT
791 Format FRED redefined at - line 5.
792 ########
793 # op.c
794 use warnings 'deprecated' ;
795 push FRED;
796 no warnings 'deprecated' ;
797 push FRED;
798 EXPECT
799 Array @FRED missing the @ in argument 1 of push() at - line 3.
800 ########
801 # op.c
802 use warnings 'deprecated' ;
803 @a = keys FRED ;
804 no warnings 'deprecated' ;
805 @a = keys FRED ;
806 EXPECT
807 Hash %FRED missing the % in argument 1 of keys() at - line 3.
808 ########
809 # op.c
810 BEGIN {
811     if ($^O eq 'MacOS') {
812         print <<EOM;
813 SKIPPED
814 # no exec on Mac OS
815 EOM
816         exit;
817     }
818 }
819 use warnings 'syntax' ;
820 exec "$^X -e 1" ; 
821 my $a
822 EXPECT
823 Statement unlikely to be reached at - line 13.
824         (Maybe you meant system() when you said exec()?)
825 ########
826 # op.c
827 use warnings 'deprecated' ;
828 my @a; defined(@a);
829 EXPECT
830 defined(@array) is deprecated at - line 3.
831         (Maybe you should just omit the defined()?)
832 ########
833 # op.c
834 use warnings 'deprecated' ;
835 defined(@a = (1,2,3));
836 EXPECT
837 defined(@array) is deprecated at - line 3.
838         (Maybe you should just omit the defined()?)
839 ########
840 # op.c
841 use warnings 'deprecated' ;
842 my %h; defined(%h);
843 EXPECT
844 defined(%hash) is deprecated at - line 3.
845         (Maybe you should just omit the defined()?)
846 ########
847 # op.c
848 BEGIN {
849     if ($^O eq 'MacOS') {
850         print <<EOM;
851 SKIPPED
852 # no exec on Mac OS
853 EOM
854         exit;
855     }
856 }
857 no warnings 'syntax' ;
858 exec "$^X -e 1" ; 
859 my $a
860 EXPECT
861
862 ########
863 # op.c
864 sub fred();
865 sub fred($) {}
866 EXPECT
867 Prototype mismatch: sub main::fred () vs ($) at - line 3.
868 ########
869 # op.c
870 $^W = 0 ;
871 sub fred() ;
872 sub fred($) {}
873 {
874     no warnings 'prototype' ;
875     sub Fred() ;
876     sub Fred($) {}
877     use warnings 'prototype' ;
878     sub freD() ;
879     sub freD($) {}
880 }
881 sub FRED() ;
882 sub FRED($) {}
883 EXPECT
884 Prototype mismatch: sub main::fred () vs ($) at - line 4.
885 Prototype mismatch: sub main::freD () vs ($) at - line 11.
886 Prototype mismatch: sub main::FRED () vs ($) at - line 14.
887 ########
888 # op.c
889 use warnings 'syntax' ;
890 join /---/, 'x', 'y', 'z';
891 EXPECT
892 /---/ should probably be written as "---" at - line 3.
893 ########
894 # op.c [Perl_peep]
895 use warnings 'prototype' ;
896 fred() ; 
897 sub fred ($$) {}
898 no warnings 'prototype' ;
899 joe() ; 
900 sub joe ($$) {}
901 EXPECT
902 main::fred() called too early to check prototype at - line 3.
903 ########
904 # op.c [Perl_newATTRSUB]
905 --FILE-- abc.pm
906 use warnings 'void' ;
907 BEGIN { $| = 1; print "in begin\n"; }
908 CHECK { print "in check\n"; }
909 INIT { print "in init\n"; }
910 END { print "in end\n"; }
911 print "in mainline\n";
912 1;
913 --FILE--
914 use abc;
915 delete $INC{"abc.pm"};
916 require abc;
917 do "abc.pm";
918 EXPECT
919 in begin
920 in mainline
921 in check
922 in init
923 in begin
924 Too late to run CHECK block at abc.pm line 3.
925 Too late to run INIT block at abc.pm line 4.
926 in mainline
927 in begin
928 Too late to run CHECK block at abc.pm line 3.
929 Too late to run INIT block at abc.pm line 4.
930 in mainline
931 in end
932 in end
933 in end
934 ########
935 # op.c [Perl_newATTRSUB]
936 --FILE-- abc.pm
937 no warnings 'void' ;
938 BEGIN { $| = 1; print "in begin\n"; }
939 CHECK { print "in check\n"; }
940 INIT { print "in init\n"; }
941 END { print "in end\n"; }
942 print "in mainline\n";
943 1;
944 --FILE--
945 require abc;
946 do "abc.pm";
947 EXPECT
948 in begin
949 in mainline
950 in begin
951 in mainline
952 in end
953 in end
954 ########
955 # op.c
956 my @x;
957 use warnings 'syntax' ;
958 push(@x);
959 unshift(@x);
960 no warnings 'syntax' ;
961 push(@x);
962 unshift(@x);
963 EXPECT
964 Useless use of push with no values at - line 4.
965 Useless use of unshift with no values at - line 5.
966 ########
967 # op.c
968 # 20020401 mjd@plover.com at suggestion of jfriedl@yahoo.com
969 use warnings 'regexp';
970 split /blah/g, "blah";
971 no warnings 'regexp';
972 split /blah/g, "blah";
973 EXPECT
974 Use of /g modifier is meaningless in split at - line 4.
975 ########
976 # op.c
977 use warnings 'precedence';
978 $a = $b & $c == $d;
979 $a = $b ^ $c != $d;
980 $a = $b | $c > $d;
981 $a = $b < $c & $d;
982 $a = $b >= $c ^ $d;
983 $a = $b <= $c | $d;
984 $a = $b <=> $c & $d;
985 no warnings 'precedence';
986 $a = $b & $c == $d;
987 $a = $b ^ $c != $d;
988 $a = $b | $c > $d;
989 $a = $b < $c & $d;
990 $a = $b >= $c ^ $d;
991 $a = $b <= $c | $d;
992 $a = $b <=> $c & $d;
993 EXPECT
994 Possible precedence problem on bitwise & operator at - line 3.
995 Possible precedence problem on bitwise ^ operator at - line 4.
996 Possible precedence problem on bitwise | operator at - line 5.
997 Possible precedence problem on bitwise & operator at - line 6.
998 Possible precedence problem on bitwise ^ operator at - line 7.
999 Possible precedence problem on bitwise | operator at - line 8.
1000 Possible precedence problem on bitwise & operator at - line 9.
1001 ########
1002 # op.c
1003 use integer;
1004 use warnings 'precedence';
1005 $a = $b & $c == $d;
1006 $a = $b ^ $c != $d;
1007 $a = $b | $c > $d;
1008 $a = $b < $c & $d;
1009 $a = $b >= $c ^ $d;
1010 $a = $b <= $c | $d;
1011 $a = $b <=> $c & $d;
1012 no warnings 'precedence';
1013 $a = $b & $c == $d;
1014 $a = $b ^ $c != $d;
1015 $a = $b | $c > $d;
1016 $a = $b < $c & $d;
1017 $a = $b >= $c ^ $d;
1018 $a = $b <= $c | $d;
1019 $a = $b <=> $c & $d;
1020 EXPECT
1021 Possible precedence problem on bitwise & operator at - line 4.
1022 Possible precedence problem on bitwise ^ operator at - line 5.
1023 Possible precedence problem on bitwise | operator at - line 6.
1024 Possible precedence problem on bitwise & operator at - line 7.
1025 Possible precedence problem on bitwise ^ operator at - line 8.
1026 Possible precedence problem on bitwise | operator at - line 9.
1027 Possible precedence problem on bitwise & operator at - line 10.