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