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