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