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