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