This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move illegalproto warnings to t/lib/warning/toke
[perl5.git] / t / lib / warnings / op
1   op.c          AOK
2
3      Found = in conditional, should be ==
4         1 if $a = 1 ;
5
6      Scalar value %.*s better written as $%.*s" 
7         @a[3] = 2;
8         @a{3} = 2;
9
10      Useless use of time in void context
11      Useless use of a variable in void context
12      Useless use of a constant in void context
13         time ;
14         $a ;
15         "abc"
16
17      Useless use of sort in scalar context
18         my $x = sort (2,1,3);
19
20      Applying %s to %s will act on scalar(%s)
21         my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
22         @a =~ /abc/ ;
23         @a =~ s/a/b/ ;
24         @a =~ tr/a/b/ ;
25         @$b =~ /abc/ ;
26         @$b =~ s/a/b/ ;
27         @$b =~ tr/a/b/ ;
28         %a =~ /abc/ ;
29         %a =~ s/a/b/ ;
30         %a =~ tr/a/b/ ;
31         %$c =~ /abc/ ;
32         %$c =~ s/a/b/ ;
33         %$c =~ tr/a/b/ ;
34
35
36      Parentheses missing around "my" list at -e line 1.
37        my $a, $b = (1,2);
38  
39      Parentheses missing around "local" list at -e line 1.
40        local $a, $b = (1,2);
41  
42      Bareword found in conditional at -e line 1.
43        use warnings 'bareword'; my $x = print(ABC || 1);
44  
45      Value of %s may be \"0\"; use \"defined\" 
46         $x = 1 if $x = <FH> ;
47         $x = 1 while $x = <FH> ;
48
49      Subroutine fred redefined at -e line 1.
50        sub fred{1;} sub fred{1;}
51  
52      Constant subroutine %s redefined 
53         sub fred() {1;} sub fred() {1;}
54  
55      Format FRED redefined at /tmp/x line 5.
56        format FRED =
57        .
58        format FRED =
59        .
60  
61      Statement unlikely to be reached
62         (Maybe you meant system() when you said exec()?
63         exec "true" ; my $a
64
65      Can't use defined(@array) (Maybe you should just omit the defined()?)
66         my @a ; defined @a ;
67         defined (@a = (1,2,3)) ;
68
69      Can't use defined(%hash) (Maybe you should just omit the defined()?)
70         my %h ; defined %h ;
71
72      "my %s" used in sort comparison
73
74      $[ used in comparison (did you mean $] ?)
75
76      length() used on @array (did you mean "scalar(@array)"?)
77      length() used on %hash (did you mean "scalar(keys %hash)"?)
78
79      /---/ should probably be written as "---"
80         join(/---/, @foo);
81
82     %s() called too early to check prototype            [Perl_peep]
83         fred() ; sub fred ($$) {}
84
85
86     Package '%s' not found (did you use the incorrect case?)
87
88     Use of /g modifier is meaningless in split
89
90     The bitwise feature is experimental                 [Perl_ck_bitop]
91
92     Possible precedence problem on bitwise %c operator  [Perl_ck_bitop]
93
94     Mandatory Warnings 
95     ------------------
96     Prototype mismatch:         [cv_ckproto]
97         sub fred() ;
98         sub fred($) {}
99
100     oops: oopsAV                [oopsAV]        TODO
101     oops: oopsHV                [oopsHV]        TODO
102     
103 __END__
104 # op.c
105 use warnings 'syntax' ;
106 1 if $a = 1 ;
107 1 if $a
108   = 1 ;
109 no warnings 'syntax' ;
110 1 if $a = 1 ;
111 1 if $a
112   = 1 ;
113 EXPECT
114 Found = in conditional, should be == at - line 3.
115 Found = in conditional, should be == at - line 4.
116 ########
117 # op.c
118 use warnings 'syntax' ;
119 use constant foo => 1;
120 1 if $a = foo ;
121 no warnings 'syntax' ;
122 1 if $a = foo ;
123 EXPECT
124 ########
125 # op.c
126 # NAME unless with assignment as condition
127 use warnings 'syntax';
128 1 unless $a = 1;
129 unless ($a = 1) {
130     1;
131 }
132 EXPECT
133 Found = in conditional, should be == at - line 3.
134 Found = in conditional, should be == at - line 4.
135 ########
136 # op.c
137 # NAME while with assignment as condition
138 use warnings 'syntax';
139 1 while $a = 0;
140 while ($a = 0) {
141     1;
142 }
143 EXPECT
144 Found = in conditional, should be == at - line 3.
145 Found = in conditional, should be == at - line 4.
146 ########
147 # op.c
148 # NAME until with assignment as condition
149 use warnings 'syntax';
150 1 until $a = 1;
151 until ($a = 1) {
152     1;
153 }
154 EXPECT
155 Found = in conditional, should be == at - line 3.
156 Found = in conditional, should be == at - line 4.
157 ########
158 # op.c
159 use warnings 'syntax' ;
160 @a[3];
161 @a{3};
162 @a["]"];
163 @a{"]"};
164 @a["}"];
165 @a{"}"};
166 @a{$_};
167 @a{--$_};
168 @a[$_];
169 @a[--$_];
170 delete @a[$x];
171 delete @a{$x};
172 no warnings 'syntax' ;
173 @a[3];
174 @a{3};
175 delete @a[$x];
176 delete @a{$x};
177 EXPECT
178 Scalar value @a[3] better written as $a[3] at - line 3.
179 Scalar value @a{3} better written as $a{3} at - line 4.
180 Scalar value @a["]"] better written as $a["]"] at - line 5.
181 Scalar value @a{"]"} better written as $a{"]"} at - line 6.
182 Scalar value @a["}"] better written as $a["}"] at - line 7.
183 Scalar value @a{"}"} better written as $a{"}"} at - line 8.
184 Scalar value @a{...} better written as $a{...} at - line 9.
185 Scalar value @a{...} better written as $a{...} at - line 10.
186 Scalar value @a[...] better written as $a[...] at - line 11.
187 Scalar value @a[...] better written as $a[...] at - line 12.
188 Scalar value @a[...] better written as $a[...] at - line 13.
189 Scalar value @a{...} better written as $a{...} at - line 14.
190 ########
191 # op.c
192 use utf8;
193 use open qw( :utf8 :std );
194 use warnings 'syntax' ;
195 @à[3];
196 @à{3};
197 no warnings 'syntax' ;
198 @à[3];
199 @à{3};
200 EXPECT
201 Scalar value @à[3] better written as $à[3] at - line 5.
202 Scalar value @à{3} better written as $à{3} at - line 6.
203 ########
204 # op.c
205 use utf8;
206 use open qw( :utf8 :std );
207 use warnings 'syntax' ;
208 @ぁ[3];
209 @ぁ{3};
210 no warnings 'syntax' ;
211 @ぁ[3];
212 @ぁ{3};
213 EXPECT
214 Scalar value @ぁ[3] better written as $ぁ[3] at - line 5.
215 Scalar value @ぁ{3} better written as $ぁ{3} at - line 6.
216 ########
217 # op.c
218 # "Scalar value better written as" false positives
219 # [perl #28380] and [perl #114024]
220 use warnings 'syntax';
221
222 # hashes
223 @h{qw"a b c"} = 1..3;
224 @h{qw'a b c'} = 1..3;
225 @h{qw$a b c$} = 1..3;
226 @h{qw-a b c-} = 1..3;
227 @h{qw#a b c#} = 1..3;
228 @h{ qw#a b c#} = 1..3;
229 @h{     qw#a b c#} = 1..3; # tab before qw
230 @h{qw "a"};
231 @h{ qw "a"};
232 @h{     qw "a"};
233 sub foo() { qw/abc def ghi/ }
234 @X{+foo} = ( 1 .. 3 );
235 $_ = "abc"; @X{split ""} = ( 1 .. 3 );
236 my @s = @f{"}", "a"};
237 my @s = @f{"]", "a"};
238 @a{$],0};
239 @_{0} = /(.*)/;
240 @h{m "$re"};
241 @h{qx ""} if 0;
242 @h{glob ""};
243 @h{readline ""};
244 @h{m ""};
245 use constant phoo => 1..3;
246 @h{+phoo}; # rv2av
247 @h{sort foo};
248 @h{reverse foo};
249 @h{caller 0};
250 @h{lstat ""};
251 @h{stat ""};
252 @h{readdir ""};
253 @h{system ""} if 0;
254 @h{+times} if 0;
255 @h{localtime 0};
256 @h{gmtime 0};
257 @h{eval ""};
258
259 # arrays
260 @h[qw"a b c"] = 1..3;
261 @h[qw'a b c'] = 1..3;
262 @h[qw$a b c$] = 1..3;
263 @h[qw-a b c-] = 1..3;
264 @h[qw#a b c#] = 1..3;
265 @h[ qw#a b c#] = 1..3;
266 @h[     qw#a b c#] = 1..3; # tab before qw
267 @h[qw "a"];
268 @h[ qw "a"];
269 @h[     qw "a"];
270 sub foo() { qw/abc def ghi/ }
271 @X[+foo] = ( 1 .. 3 );
272 $_ = "abc"; @X[split ""] = ( 1 .. 3 );
273 my @s = @f["}", "a"];
274 my @s = @f["]", "a"];
275 @a[$],0];
276 @_[0] = /(.*)/;
277 @h[m "$re"];
278 @h[qx ""] if 0;
279 @h[glob ""];
280 @h[readline ""];
281 @h[m ""];
282 use constant phoo => 1..3;
283 @h[+phoo]; # rv2av
284 @h[sort foo];
285 @h[reverse foo];
286 @h[caller 0];
287 @h[lstat ""];
288 @h[stat ""];
289 @h[readdir ""];
290 @h[system ""] if 0;
291 @h[+times] if 0;
292 @h[localtime 0];
293 @h[gmtime 0];
294 @h[eval ""];
295 EXPECT
296 ########
297 # op.c
298 # "Scalar value better written as" should not trigger for syntax errors
299 use warnings 'syntax';
300 @a[]
301 EXPECT
302 syntax error at - line 4, near "[]"
303 Execution of - aborted due to compilation errors.
304 ########
305 # op.c
306 my %foo;
307 %main::foo->{"bar"};
308 EXPECT
309 OPTION fatal
310 Can't use a hash as a reference at - line 3.
311 ########
312 # op.c
313 my %foo;
314 %foo->{"bar"};
315 EXPECT
316 OPTION fatal
317 Can't use a hash as a reference at - line 3.
318 ########
319 # op.c
320 my @foo;
321 @main::foo->[23];
322 EXPECT
323 OPTION fatal
324 Can't use an array as a reference at - line 3.
325 ########
326 # op.c
327 my @foo;
328 @foo->[23];
329 EXPECT
330 OPTION fatal
331 Can't use an array as a reference at - line 3.
332 ########
333 # op.c
334 my %foo;
335 $main::foo = {}; %$main::foo->{"bar"};
336 EXPECT
337 OPTION fatal
338 Can't use a hash as a reference at - line 3.
339 ########
340 # op.c
341 my %foo;
342 $foo = {}; %$foo->{"bar"};
343 EXPECT
344 OPTION fatal
345 Can't use a hash as a reference at - line 3.
346 ########
347 # op.c
348 my @foo;
349 $main::foo = []; @$main::foo->[34];
350 EXPECT
351 OPTION fatal
352 Can't use an array as a reference at - line 3.
353 ########
354 # op.c
355 my @foo;
356 $foo = []; @$foo->[34];
357 EXPECT
358 OPTION fatal
359 Can't use an array as a reference at - line 3.
360 ########
361 # op.c
362 use warnings 'void' ; no warnings 'experimental::smartmatch'; close STDIN ;
363 #line 2
364 1 x 3 ;                 # OP_REPEAT (folded)
365 (1) x 3 ;               # OP_REPEAT
366                         # OP_GVSV
367 wantarray ;             # OP_WANTARRAY
368                         # OP_GV
369                         # OP_PADSV
370                         # OP_PADAV
371                         # OP_PADHV
372                         # OP_PADANY
373                         # OP_AV2ARYLEN
374 ref ;                   # OP_REF
375 \(@a) ;                 # OP_REFGEN
376 \$a ;                   # OP_SREFGEN
377 defined $a ;            # OP_DEFINED
378 hex $a ;                # OP_HEX
379 oct $a ;                # OP_OCT
380 length $a ;             # OP_LENGTH
381 substr $a,1 ;           # OP_SUBSTR
382 vec $a,1,2 ;            # OP_VEC
383 index $a,1,2 ;          # OP_INDEX
384 rindex $a,1,2 ;         # OP_RINDEX
385 sprintf $a ;            # OP_SPRINTF
386 $a[0] ;                 # OP_AELEM
387                         # OP_AELEMFAST
388 @a[0] ;                 # OP_ASLICE
389 #values %a ;            # OP_VALUES
390 #keys %a ;              # OP_KEYS
391 $a{0} ;                 # OP_HELEM
392 @a{0} ;                 # OP_HSLICE
393 unpack "a", "a" ;       # OP_UNPACK
394 pack $a,"" ;            # OP_PACK
395 join "", @_ ;           # OP_JOIN
396 (@a)[0,1] ;             # OP_LSLICE
397                         # OP_ANONLIST
398                         # OP_ANONHASH
399 sort(1,2) ;             # OP_SORT
400 reverse(1,2) ;          # OP_REVERSE
401                         # OP_RANGE
402                         # OP_FLIP
403 (1 ..2) ;               # OP_FLOP
404 caller ;                # OP_CALLER
405 fileno STDIN ;          # OP_FILENO
406 eof STDIN ;             # OP_EOF
407 tell STDIN ;            # OP_TELL
408 readlink 1;             # OP_READLINK
409 time ;                  # OP_TIME
410 localtime ;             # OP_LOCALTIME
411 gmtime ;                # OP_GMTIME
412 eval { getgrnam 1 };    # OP_GGRNAM
413 eval { getgrgid 1 };    # OP_GGRGID
414 eval { getpwnam 1 };    # OP_GPWNAM
415 eval { getpwuid 1 };    # OP_GPWUID
416 prototype "foo";        # OP_PROTOTYPE
417 $a ~~ $b;               # OP_SMARTMATCH
418 $a <=> $b;              # OP_NCMP
419 "dsatrewq";
420 "diatrewq";
421 "igatrewq";
422 use 5.015;
423 __SUB__ ;               # OP_RUNCV
424 [];                     # OP_ANONLIST
425 grep /42/, (1,2);       # OP_GREP. Not warned about (yet). Grep git logs for void_unusual to see why...
426 EXPECT
427 Useless use of a constant ("111") in void context at - line 2.
428 Useless use of repeat (x) in void context at - line 3.
429 Useless use of wantarray in void context at - line 5.
430 Useless use of reference-type operator in void context at - line 12.
431 Useless use of reference constructor in void context at - line 13.
432 Useless use of single ref constructor in void context at - line 14.
433 Useless use of defined operator in void context at - line 15.
434 Useless use of hex in void context at - line 16.
435 Useless use of oct in void context at - line 17.
436 Useless use of length in void context at - line 18.
437 Useless use of substr in void context at - line 19.
438 Useless use of vec in void context at - line 20.
439 Useless use of index in void context at - line 21.
440 Useless use of rindex in void context at - line 22.
441 Useless use of sprintf in void context at - line 23.
442 Useless use of array element in void context at - line 24.
443 Useless use of array slice in void context at - line 26.
444 Useless use of hash element in void context at - line 29.
445 Useless use of hash slice in void context at - line 30.
446 Useless use of unpack in void context at - line 31.
447 Useless use of pack in void context at - line 32.
448 Useless use of join or string in void context at - line 33.
449 Useless use of list slice in void context at - line 34.
450 Useless use of sort in void context at - line 37.
451 Useless use of reverse in void context at - line 38.
452 Useless use of range (or flop) in void context at - line 41.
453 Useless use of caller in void context at - line 42.
454 Useless use of fileno in void context at - line 43.
455 Useless use of eof in void context at - line 44.
456 Useless use of tell in void context at - line 45.
457 Useless use of readlink in void context at - line 46.
458 Useless use of time in void context at - line 47.
459 Useless use of localtime in void context at - line 48.
460 Useless use of gmtime in void context at - line 49.
461 Useless use of getgrnam in void context at - line 50.
462 Useless use of getgrgid in void context at - line 51.
463 Useless use of getpwnam in void context at - line 52.
464 Useless use of getpwuid in void context at - line 53.
465 Useless use of subroutine prototype in void context at - line 54.
466 Useless use of smart match in void context at - line 55.
467 Useless use of numeric comparison (<=>) in void context at - line 56.
468 Useless use of a constant ("dsatrewq") in void context at - line 57.
469 Useless use of a constant ("diatrewq") in void context at - line 58.
470 Useless use of a constant ("igatrewq") in void context at - line 59.
471 Useless use of __SUB__ in void context at - line 61.
472 Useless use of anonymous array ([]) in void context at - line 62.
473 ########
474 # op.c
475 use warnings 'void' ; close STDIN ;
476 my $x = sort (2,1,3);
477 no warnings 'void' ;
478 $x = sort (2,1,3);
479 EXPECT
480 Useless use of sort in scalar context at - line 3.
481 ########
482 # op.c
483 no warnings 'void' ; close STDIN ;
484 1 x 3 ;                 # OP_REPEAT
485                         # OP_GVSV
486 wantarray ;             # OP_WANTARRAY
487                         # OP_GV
488                         # OP_PADSV
489                         # OP_PADAV
490                         # OP_PADHV
491                         # OP_PADANY
492                         # OP_AV2ARYLEN
493 ref ;                   # OP_REF
494 \@a ;                   # OP_REFGEN
495 \$a ;                   # OP_SREFGEN
496 defined $a ;            # OP_DEFINED
497 hex $a ;                # OP_HEX
498 oct $a ;                # OP_OCT
499 length $a ;             # OP_LENGTH
500 substr $a,1 ;           # OP_SUBSTR
501 vec $a,1,2 ;            # OP_VEC
502 index $a,1,2 ;          # OP_INDEX
503 rindex $a,1,2 ;         # OP_RINDEX
504 sprintf $a ;            # OP_SPRINTF
505 $a[0] ;                 # OP_AELEM
506                         # OP_AELEMFAST
507 @a[0] ;                 # OP_ASLICE
508 #values %a ;            # OP_VALUES
509 #keys %a ;              # OP_KEYS
510 $a{0} ;                 # OP_HELEM
511 @a{0} ;                 # OP_HSLICE
512 unpack "a", "a" ;       # OP_UNPACK
513 pack $a,"" ;            # OP_PACK
514 join "" ;               # OP_JOIN
515 (@a)[0,1] ;             # OP_LSLICE
516                         # OP_ANONLIST
517                         # OP_ANONHASH
518 sort(1,2) ;             # OP_SORT
519 reverse(1,2) ;          # OP_REVERSE
520                         # OP_RANGE
521                         # OP_FLIP
522 (1 ..2) ;               # OP_FLOP
523 caller ;                # OP_CALLER
524 fileno STDIN ;          # OP_FILENO
525 eof STDIN ;             # OP_EOF
526 tell STDIN ;            # OP_TELL
527 readlink 1;             # OP_READLINK
528 time ;                  # OP_TIME
529 localtime ;             # OP_LOCALTIME
530 gmtime ;                # OP_GMTIME
531 eval { getgrnam 1 };    # OP_GGRNAM
532 eval { getgrgid 1 };    # OP_GGRGID
533 eval { getpwnam 1 };    # OP_GPWNAM
534 eval { getpwuid 1 };    # OP_GPWUID
535 prototype "foo";        # OP_PROTOTYPE
536 EXPECT
537 ########
538 # op.c
539 use warnings 'void' ;
540 for (@{[0]}) { "$_" }           # check warning isn't duplicated
541 no warnings 'void' ;
542 for (@{[0]}) { "$_" }           # check warning isn't duplicated
543 EXPECT
544 Useless use of string in void context at - line 3.
545 ########
546 # op.c
547 use warnings 'void' ;
548 use Config ;
549 BEGIN {
550     if ( ! $Config{d_telldir}) {
551         print <<EOM ;
552 SKIPPED
553 # telldir not present
554 EOM
555         exit 
556     }
557 }
558 telldir 1 ;             # OP_TELLDIR
559 no warnings 'void' ;
560 telldir 1 ;             # OP_TELLDIR
561 EXPECT
562 Useless use of telldir in void context at - line 13.
563 ########
564 # op.c
565 use warnings 'void' ;
566 use Config ;
567 BEGIN {
568     if ( ! $Config{d_getppid}) {
569         print <<EOM ;
570 SKIPPED
571 # getppid not present
572 EOM
573         exit 
574     }
575 }
576 getppid ;               # OP_GETPPID
577 no warnings 'void' ;
578 getppid ;               # OP_GETPPID
579 EXPECT
580 Useless use of getppid in void context at - line 13.
581 ########
582 # op.c
583 use warnings 'void' ;
584 use Config ;
585 BEGIN {
586     if ( ! $Config{d_getpgrp}) {
587         print <<EOM ;
588 SKIPPED
589 # getpgrp not present
590 EOM
591         exit 
592     }
593 }
594 getpgrp ;               # OP_GETPGRP
595 no warnings 'void' ;
596 getpgrp ;               # OP_GETPGRP
597 EXPECT
598 Useless use of getpgrp in void context at - line 13.
599 ########
600 # op.c
601 use warnings 'void' ;
602 use Config ;
603 BEGIN {
604     if ( ! $Config{d_times}) {
605         print <<EOM ;
606 SKIPPED
607 # times not present
608 EOM
609         exit 
610     }
611 }
612 times ;                 # OP_TMS
613 no warnings 'void' ;
614 times ;                 # OP_TMS
615 EXPECT
616 Useless use of times in void context at - line 13.
617 ########
618 # op.c
619 use warnings 'void' ;
620 use Config ;
621 BEGIN {
622     if ( ! $Config{d_getprior} or $^O eq 'os2') { # Locks before fixpak22
623         print <<EOM ;
624 SKIPPED
625 # getpriority not present
626 EOM
627         exit 
628     }
629 }
630 getpriority 1,2;        # OP_GETPRIORITY
631 no warnings 'void' ;
632 getpriority 1,2;        # OP_GETPRIORITY
633 EXPECT
634 Useless use of getpriority in void context at - line 13.
635 ########
636 # op.c
637 use warnings 'void' ;
638 use Config ;
639 BEGIN {
640     if ( ! $Config{d_getlogin}) {
641         print <<EOM ;
642 SKIPPED
643 # getlogin not present
644 EOM
645         exit 
646     }
647 }
648 getlogin ;                      # OP_GETLOGIN
649 no warnings 'void' ;
650 getlogin ;                      # OP_GETLOGIN
651 EXPECT
652 Useless use of getlogin in void context at - line 13.
653 ########
654 # op.c
655 use warnings 'void' ;
656 use Config ; BEGIN {
657 if ( ! $Config{d_socket}) {
658     print <<EOM ;
659 SKIPPED
660 # getsockname not present
661 # getpeername not present
662 # gethostbyname not present
663 # gethostbyaddr not present
664 # gethostent not present
665 # getnetbyname not present
666 # getnetbyaddr not present
667 # getnetent not present
668 # getprotobyname not present
669 # getprotobynumber not present
670 # getprotoent not present
671 # getservbyname not present
672 # getservbyport not present
673 # getservent not present
674 EOM
675     exit 
676 } }
677 getsockname STDIN ;     # OP_GETSOCKNAME
678 getpeername STDIN ;     # OP_GETPEERNAME
679 gethostbyname 1 ;       # OP_GHBYNAME
680 gethostbyaddr 1,2;      # OP_GHBYADDR
681 gethostent ;            # OP_GHOSTENT
682 getnetbyname 1 ;        # OP_GNBYNAME
683 getnetbyaddr 1,2 ;      # OP_GNBYADDR
684 getnetent ;             # OP_GNETENT
685 getprotobyname 1;       # OP_GPBYNAME
686 getprotobynumber 1;     # OP_GPBYNUMBER
687 getprotoent ;           # OP_GPROTOENT
688 getservbyname 1,2;      # OP_GSBYNAME
689 getservbyport 1,2;      # OP_GSBYPORT
690 getservent ;            # OP_GSERVENT
691
692 no warnings 'void' ;
693 getsockname STDIN ;     # OP_GETSOCKNAME
694 getpeername STDIN ;     # OP_GETPEERNAME
695 gethostbyname 1 ;       # OP_GHBYNAME
696 gethostbyaddr 1,2;      # OP_GHBYADDR
697 gethostent ;            # OP_GHOSTENT
698 getnetbyname 1 ;        # OP_GNBYNAME
699 getnetbyaddr 1,2 ;      # OP_GNBYADDR
700 getnetent ;             # OP_GNETENT
701 getprotobyname 1;       # OP_GPBYNAME
702 getprotobynumber 1;     # OP_GPBYNUMBER
703 getprotoent ;           # OP_GPROTOENT
704 getservbyname 1,2;      # OP_GSBYNAME
705 getservbyport 1,2;      # OP_GSBYPORT
706 getservent ;            # OP_GSERVENT
707 INIT {
708    # some functions may not be there, so we exit without running
709    exit;
710 }
711 EXPECT
712 Useless use of getsockname in void context at - line 24.
713 Useless use of getpeername in void context at - line 25.
714 Useless use of gethostbyname in void context at - line 26.
715 Useless use of gethostbyaddr in void context at - line 27.
716 Useless use of gethostent in void context at - line 28.
717 Useless use of getnetbyname in void context at - line 29.
718 Useless use of getnetbyaddr in void context at - line 30.
719 Useless use of getnetent in void context at - line 31.
720 Useless use of getprotobyname in void context at - line 32.
721 Useless use of getprotobynumber in void context at - line 33.
722 Useless use of getprotoent in void context at - line 34.
723 Useless use of getservbyname in void context at - line 35.
724 Useless use of getservbyport in void context at - line 36.
725 Useless use of getservent in void context at - line 37.
726 ########
727 # op.c
728 use warnings 'void' ;
729 *a ; # OP_RV2GV
730 $a ; # OP_RV2SV
731 @a ; # OP_RV2AV
732 %a ; # OP_RV2HV
733 no warnings 'void' ;
734 *a ; # OP_RV2GV
735 $a ; # OP_RV2SV
736 @a ; # OP_RV2AV
737 %a ; # OP_RV2HV
738 EXPECT
739 Useless use of a variable in void context at - line 3.
740 Useless use of a variable in void context at - line 4.
741 Useless use of a variable in void context at - line 5.
742 Useless use of a variable in void context at - line 6.
743 ########
744 # op.c
745 use warnings 'void' ;
746 "abc"; # OP_CONST
747 7 ; # OP_CONST
748 "x" . "y"; # optimized to OP_CONST
749 2 + 2; # optimized to OP_CONST
750 use constant U => undef;
751 U;
752 qq/"    \n/;
753 5 || print "bad\n";     # test OPpCONST_SHORTCIRCUIT
754 print "boo\n" if U;     # test OPpCONST_SHORTCIRCUIT
755 if($foo){}elsif(""){}   # test OPpCONST_SHORTCIRCUIT
756 no warnings 'void' ;
757 "abc"; # OP_CONST
758 7 ; # OP_CONST
759 "x" . "y"; # optimized to OP_CONST
760 2 + 2; # optimized to OP_CONST
761 EXPECT
762 Useless use of a constant ("abc") in void context at - line 3.
763 Useless use of a constant (7) in void context at - line 4.
764 Useless use of a constant ("xy") in void context at - line 5.
765 Useless use of a constant (4) in void context at - line 6.
766 Useless use of a constant (undef) in void context at - line 8.
767 Useless use of a constant ("\"\t\n") in void context at - line 9.
768 ########
769 # op.c
770 BEGIN {
771     if (ord('A') == 193) {
772         print "SKIPPED\n# Result varies depending on EBCDIC code page";
773         exit 0;
774     }
775 }
776 use utf8;
777 use open qw( :utf8 :std );
778 use warnings 'void' ;
779 "àḆc"; # OP_CONST
780 EXPECT
781 Useless use of a constant ("\340\x{1e06}c") in void context at - line 11.
782 ########
783 # op.c
784 use utf8;
785 use open qw( :utf8 :std );
786 use warnings 'void' ;
787 "Ẋ" . "ƴ"; # optimized to OP_CONST
788 FOO;     # Bareword optimized to OP_CONST
789 use constant ů => undef;
790 ů;
791 5 || print "bad\n";     # test OPpCONST_SHORTCIRCUIT
792 print "boo\n" if ů;    # test OPpCONST_SHORTCIRCUIT
793 no warnings 'void' ;
794 "àḆc"; # OP_CONST
795 "Ẋ" . "ƴ"; # optimized to OP_CONST
796 EXPECT
797 Useless use of a constant ("\x{1e8a}\x{1b4}") in void context at - line 5.
798 Useless use of a constant ("\x{ff26}\x{ff2f}\x{ff2f}") in void context at - line 6.
799 Useless use of a constant (undef) in void context at - line 8.
800 ########
801 # op.c
802 #
803 use warnings 'misc' ; use utf8;
804 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;my $d = 'test';
805 @a =~ /abc/ ;
806 @a2 =~ s/a/b/ ;
807 @a3 =~ tr/a/b/ ;
808 @$b =~ /abc/ ;
809 @$b =~ s/a/b/ ;
810 @$b =~ tr/a/b/ ;
811 %a =~ /abc/ ;
812 %a2 =~ s/a/b/ ;
813 %a3 =~ tr/a/b/ ;
814 %$c =~ /abc/ ;
815 %$c =~ s/a/b/ ;
816 %$c =~ tr/a/b/ ;
817 $d =~ tr/a/b/d ;
818 $d2 =~ tr/a/bc/;
819 $d3 =~ tr//b/c;
820 $d =~ tr/α/β/d ;
821 $d2 =~ tr/α/βγ/;
822 {
823 no warnings 'misc' ;
824 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ; my $d = 'test';
825 @a =~ /abc/ ;
826 @a =~ s/a/b/ ;
827 @a =~ tr/a/b/ ;
828 @$b =~ /abc/ ;
829 @$b =~ s/a/b/ ;
830 @$b =~ tr/a/b/ ;
831 %a =~ /abc/ ;
832 %a =~ s/a/b/ ;
833 %a =~ tr/a/b/ ;
834 %$c =~ /abc/ ;
835 %$c =~ s/a/b/ ;
836 %$c =~ tr/a/b/ ;
837 $d =~ tr/a/b/d ;
838 $d =~ tr/a/bc/ ;
839 $d =~ tr//b/c;
840 }
841 EXPECT
842 Applying pattern match (m//) to @a will act on scalar(@a) at - line 5.
843 Applying substitution (s///) to @a2 will act on scalar(@a2) at - line 6.
844 Applying transliteration (tr///) to @a3 will act on scalar(@a3) at - line 7.
845 Applying pattern match (m//) to @array will act on scalar(@array) at - line 8.
846 Applying substitution (s///) to @array will act on scalar(@array) at - line 9.
847 Applying transliteration (tr///) to @array will act on scalar(@array) at - line 10.
848 Applying pattern match (m//) to %a will act on scalar(%a) at - line 11.
849 Applying substitution (s///) to %a2 will act on scalar(%a2) at - line 12.
850 Applying transliteration (tr///) to %a3 will act on scalar(%a3) at - line 13.
851 Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 14.
852 Applying substitution (s///) to %hash will act on scalar(%hash) at - line 15.
853 Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 16.
854 Useless use of /d modifier in transliteration operator at - line 17.
855 Replacement list is longer than search list at - line 18.
856 Useless use of /d modifier in transliteration operator at - line 20.
857 Replacement list is longer than search list at - line 21.
858 Can't modify array dereference in substitution (s///) at - line 6, near "s/a/b/ ;"
859 BEGIN not safe after errors--compilation aborted at - line 23.
860 ########
861 # op.c
862 use warnings 'parenthesis' ;
863 my $a, $b = (1,2);
864 my @foo,%bar,   $quux; # there's a TAB here
865 my $x, $y or print;
866 my $p, *q;
867 no warnings 'parenthesis' ;
868 my $c, $d = (1,2);
869 EXPECT
870 Parentheses missing around "my" list at - line 3.
871 Parentheses missing around "my" list at - line 4.
872 ########
873 # op.c
874 use warnings 'parenthesis' ;
875 our $a, $b = (1,2);
876 our $p, *q;
877 no warnings 'parenthesis' ;
878 our $c, $d = (1,2);
879 EXPECT
880 Parentheses missing around "our" list at - line 3.
881 ########
882 # op.c
883 use warnings 'parenthesis' ;
884 local $a, $b = (1,2);
885 local *f, *g;
886 local $p, *q;
887 no warnings 'parenthesis' ;
888 local $c, $d = (1,2);
889 EXPECT
890 Parentheses missing around "local" list at - line 3.
891 Parentheses missing around "local" list at - line 4.
892 Parentheses missing around "local" list at - line 5.
893 ########
894 # op.c
895 use warnings 'bareword' ;
896 print (ABC || 1) ;
897 no warnings 'bareword' ;
898 print (ABC || 1) ;
899 EXPECT
900 Bareword found in conditional at - line 3.
901 ########
902 --FILE-- abc
903
904 --FILE--
905 # op.c
906 use warnings 'misc' ;
907 open FH, "<abc" ;
908 $x = 1 if $x = <FH> ;
909 $x = 1 if $x
910      = <FH> ;
911 no warnings 'misc' ;
912 $x = 1 if $x = <FH> ;
913 $x = 1 if $x
914      = <FH> ;
915 EXPECT
916 Value of <HANDLE> construct can be "0"; test with defined() at - line 4.
917 Value of <HANDLE> construct can be "0"; test with defined() at - line 5.
918 ########
919 # op.c
920 use warnings 'misc' ;
921 opendir FH, "." ;
922 $x = 1 if $x = readdir FH ;
923 $x = 1 if $x
924     = readdir FH ;
925 no warnings 'misc' ;
926 $x = 1 if $x = readdir FH ;
927 $x = 1 if $x
928     = readdir FH ;
929 closedir FH ;
930 EXPECT
931 Value of readdir() operator can be "0"; test with defined() at - line 4.
932 Value of readdir() operator can be "0"; test with defined() at - line 5.
933 ########
934 # op.c
935 use warnings 'misc' ;
936 $x = 1 if $x = <*> ;
937 $x = 1 if $x
938     = <*> ;
939 no warnings 'misc' ;
940 $x = 1 if $x = <*> ;
941 $x = 1 if $x
942     = <*> ;
943 EXPECT
944 Value of glob construct can be "0"; test with defined() at - line 3.
945 Value of glob construct can be "0"; test with defined() at - line 4.
946 ########
947 # op.c
948 use warnings 'misc' ;
949 %a = (1,2,3,4) ;
950 $x = 1 if $x = each %a ;
951 no warnings 'misc' ;
952 $x = 1 if $x = each %a ;
953 EXPECT
954 Value of each() operator can be "0"; test with defined() at - line 4.
955 ########
956 # op.c
957 use warnings 'misc' ;
958 $x = 1 while $x = <*> and 0 ;
959 no warnings 'misc' ;
960 $x = 1 while $x = <*> and 0 ;
961 EXPECT
962 Value of glob construct can be "0"; test with defined() at - line 3.
963 ########
964 # op.c
965 use warnings 'misc' ;
966 opendir FH, "." ;
967 $x = 1 while $x = readdir FH and 0 ;
968 no warnings 'misc' ;
969 $x = 1 while $x = readdir FH and 0 ;
970 closedir FH ;
971 EXPECT
972 Value of readdir() operator can be "0"; test with defined() at - line 4.
973 ########
974 # op.c
975 use warnings 'misc';
976 open FH, "<abc";
977 ($_ = <FH>) // ($_ = 1);
978 opendir DH, ".";
979 %a = (1,2,3,4) ;
980 EXPECT
981 ########
982 # op.c
983 use warnings 'redefine' ;
984 sub fred {}
985 sub fred {}
986 sub fred { # warning should be for this line
987 }
988 no warnings 'redefine' ;
989 sub fred {}
990 sub fred {
991 }
992 EXPECT
993 Subroutine fred redefined at - line 4.
994 Subroutine fred redefined at - line 5.
995 ########
996 # op.c
997 use warnings 'redefine' ;
998 sub fred () { 1 }
999 sub fred () { 1 }
1000 no warnings 'redefine' ;
1001 sub fred () { 1 }
1002 EXPECT
1003 Constant subroutine fred redefined at - line 4.
1004 ########
1005 # op.c
1006 sub fred () { 1 }
1007 sub fred () { 2 }
1008 EXPECT
1009 Constant subroutine fred redefined at - line 3.
1010 ########
1011 # op.c
1012 sub fred () { 1 }
1013 *fred = sub () { 2 };
1014 EXPECT
1015 Constant subroutine main::fred redefined at - line 3.
1016 ########
1017 # op.c
1018 use feature "lexical_subs", "state";
1019 my sub fred () { 1 }
1020 sub fred { 2 };
1021 my sub george { 1 }
1022 sub george () { 2 } # should *not* produce redef warnings by default
1023 state sub phred () { 1 }
1024 sub phred { 2 };
1025 state sub jorge { 1 }
1026 sub jorge () { 2 } # should *not* produce redef warnings by default
1027 EXPECT
1028 Prototype mismatch: sub fred () vs none at - line 4.
1029 Constant subroutine fred redefined at - line 4.
1030 Prototype mismatch: sub george: none vs () at - line 6.
1031 Prototype mismatch: sub phred () vs none at - line 8.
1032 Constant subroutine phred redefined at - line 8.
1033 Prototype mismatch: sub jorge: none vs () at - line 10.
1034 ########
1035 # op.c
1036 no warnings 'redefine' ;
1037 sub fred () { 1 }
1038 sub fred () { 2 }
1039 EXPECT
1040 ########
1041 # op.c
1042 no warnings 'redefine' ;
1043 sub fred () { 1 }
1044 *fred = sub () { 2 };
1045 EXPECT
1046 ########
1047 # op.c
1048 use warnings 'redefine' ;
1049 format FRED =
1050 .
1051 format FRED =
1052 .
1053 no warnings 'redefine' ;
1054 format FRED =
1055 .
1056 EXPECT
1057 Format FRED redefined at - line 5.
1058 ########
1059 # op.c
1060 use warnings 'exec' ;
1061 exec "$^X -e 1" ; 
1062 my $a
1063 EXPECT
1064 Statement unlikely to be reached at - line 4.
1065         (Maybe you meant system() when you said exec()?)
1066 ########
1067 # op.c, no warning if exec isn't a statement.
1068 use warnings 'exec' ;
1069 $a || exec "$^X -e 1" ;
1070 my $a
1071 EXPECT
1072 ########
1073 # op.c
1074 defined(@a);
1075 EXPECT
1076 OPTION fatal
1077 Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at - line 2.
1078 ########
1079 # op.c
1080 my @a; defined(@a);
1081 EXPECT
1082 OPTION fatal
1083 Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at - line 2.
1084 ########
1085 # op.c
1086 defined(@a = (1,2,3));
1087 EXPECT
1088 ########
1089 # op.c
1090 defined(%h);
1091 EXPECT
1092 OPTION fatal
1093 Can't use 'defined(%hash)' (Maybe you should just omit the defined()?) at - line 2.
1094 ########
1095 # op.c
1096 my %h; defined(%h);
1097 EXPECT
1098 OPTION fatal
1099 Can't use 'defined(%hash)' (Maybe you should just omit the defined()?) at - line 2.
1100 ########
1101 # op.c
1102 no warnings 'exec' ;
1103 exec "$^X -e 1" ; 
1104 my $a
1105 EXPECT
1106
1107 ########
1108 # op.c
1109 sub fred();
1110 sub fred($) {}
1111 use constant foo=>bar; sub foo(@);
1112 use constant bav=>bar; sub bav(); # no warning
1113 sub btu; sub btu();
1114 EXPECT
1115 Prototype mismatch: sub main::fred () vs ($) at - line 3.
1116 Prototype mismatch: sub foo () vs (@) at - line 4.
1117 Prototype mismatch: sub btu: none vs () at - line 6.
1118 ########
1119 # op.c
1120 use utf8;
1121 use open qw( :utf8 :std );
1122 sub frèd();
1123 sub frèd($) {}
1124 EXPECT
1125 Prototype mismatch: sub main::frèd () vs ($) at - line 5.
1126 ########
1127 # op.c
1128 use utf8;
1129 use open qw( :utf8 :std );
1130 use warnings;
1131 BEGIN { $::{"foo"} = "\x{30cb}" }
1132 BEGIN { eval "sub foo {}"; }
1133 EXPECT
1134 Prototype mismatch: sub main::foo (ニ) vs none at (eval 1) line 1.
1135 ########
1136 # op.c
1137 $^W = 0 ;
1138 sub fred() ;
1139 sub fred($) {}
1140 {
1141     no warnings 'prototype' ;
1142     sub Fred() ;
1143     sub Fred($) {}
1144     use warnings 'prototype' ;
1145     sub freD() ;
1146     sub freD($) {}
1147 }
1148 sub FRED() ;
1149 sub FRED($) {}
1150 EXPECT
1151 Prototype mismatch: sub main::fred () vs ($) at - line 4.
1152 Prototype mismatch: sub main::freD () vs ($) at - line 11.
1153 Prototype mismatch: sub main::FRED () vs ($) at - line 14.
1154 ########
1155 # op.c [S_simplify_sort]
1156 # [perl #86136]
1157 my @tests = split /^/, '
1158   sort {$a <=> $b} @a;
1159   sort {$a cmp $b} @a;
1160   { use integer; sort {$a <=> $b} @a}
1161   sort {$b <=> $a} @a;
1162   sort {$b cmp $a} @a;
1163   { use integer; sort {$b <=> $a} @a}
1164 ';
1165 for my $pragma ('use warnings "syntax";', '') {
1166   for my $vars ('', 'my $a;', 'my $b;', 'my ($a,$b);') {
1167     for my $inner_stmt ('', 'print;', 'func();') {
1168       eval "#line " . ++$line . "01 -\n$pragma\n$vars"
1169           . join "", map s/sort \{\K/$inner_stmt/r, @tests;
1170       $@ and die;
1171     }
1172   }
1173 }
1174 sub func{}
1175 use warnings 'syntax';
1176 my $a;
1177 # These used to be errors!
1178 sort { ; } $a <=> $b;
1179 sort { ; } $a, "<=>";
1180 sort { ; } $a, $cmp;
1181 sort $a, $b if $cmpany_name;
1182 sort if $a + $cmp;
1183 sort @t; $a + $cmp;
1184 EXPECT
1185 "my $a" used in sort comparison at - line 403.
1186 "my $a" used in sort comparison at - line 404.
1187 "my $a" used in sort comparison at - line 405.
1188 "my $a" used in sort comparison at - line 406.
1189 "my $a" used in sort comparison at - line 407.
1190 "my $a" used in sort comparison at - line 408.
1191 "my $a" used in sort comparison at - line 503.
1192 "my $a" used in sort comparison at - line 504.
1193 "my $a" used in sort comparison at - line 505.
1194 "my $a" used in sort comparison at - line 506.
1195 "my $a" used in sort comparison at - line 507.
1196 "my $a" used in sort comparison at - line 508.
1197 "my $a" used in sort comparison at - line 603.
1198 "my $a" used in sort comparison at - line 604.
1199 "my $a" used in sort comparison at - line 605.
1200 "my $a" used in sort comparison at - line 606.
1201 "my $a" used in sort comparison at - line 607.
1202 "my $a" used in sort comparison at - line 608.
1203 "my $b" used in sort comparison at - line 703.
1204 "my $b" used in sort comparison at - line 704.
1205 "my $b" used in sort comparison at - line 705.
1206 "my $b" used in sort comparison at - line 706.
1207 "my $b" used in sort comparison at - line 707.
1208 "my $b" used in sort comparison at - line 708.
1209 "my $b" used in sort comparison at - line 803.
1210 "my $b" used in sort comparison at - line 804.
1211 "my $b" used in sort comparison at - line 805.
1212 "my $b" used in sort comparison at - line 806.
1213 "my $b" used in sort comparison at - line 807.
1214 "my $b" used in sort comparison at - line 808.
1215 "my $b" used in sort comparison at - line 903.
1216 "my $b" used in sort comparison at - line 904.
1217 "my $b" used in sort comparison at - line 905.
1218 "my $b" used in sort comparison at - line 906.
1219 "my $b" used in sort comparison at - line 907.
1220 "my $b" used in sort comparison at - line 908.
1221 "my $a" used in sort comparison at - line 1003.
1222 "my $b" used in sort comparison at - line 1003.
1223 "my $a" used in sort comparison at - line 1004.
1224 "my $b" used in sort comparison at - line 1004.
1225 "my $a" used in sort comparison at - line 1005.
1226 "my $b" used in sort comparison at - line 1005.
1227 "my $b" used in sort comparison at - line 1006.
1228 "my $a" used in sort comparison at - line 1006.
1229 "my $b" used in sort comparison at - line 1007.
1230 "my $a" used in sort comparison at - line 1007.
1231 "my $b" used in sort comparison at - line 1008.
1232 "my $a" used in sort comparison at - line 1008.
1233 "my $a" used in sort comparison at - line 1103.
1234 "my $b" used in sort comparison at - line 1103.
1235 "my $a" used in sort comparison at - line 1104.
1236 "my $b" used in sort comparison at - line 1104.
1237 "my $a" used in sort comparison at - line 1105.
1238 "my $b" used in sort comparison at - line 1105.
1239 "my $b" used in sort comparison at - line 1106.
1240 "my $a" used in sort comparison at - line 1106.
1241 "my $b" used in sort comparison at - line 1107.
1242 "my $a" used in sort comparison at - line 1107.
1243 "my $b" used in sort comparison at - line 1108.
1244 "my $a" used in sort comparison at - line 1108.
1245 "my $a" used in sort comparison at - line 1203.
1246 "my $b" used in sort comparison at - line 1203.
1247 "my $a" used in sort comparison at - line 1204.
1248 "my $b" used in sort comparison at - line 1204.
1249 "my $a" used in sort comparison at - line 1205.
1250 "my $b" used in sort comparison at - line 1205.
1251 "my $b" used in sort comparison at - line 1206.
1252 "my $a" used in sort comparison at - line 1206.
1253 "my $b" used in sort comparison at - line 1207.
1254 "my $a" used in sort comparison at - line 1207.
1255 "my $b" used in sort comparison at - line 1208.
1256 "my $a" used in sort comparison at - line 1208.
1257 ########
1258 # op.c [S_simplify_sort]
1259 use warnings 'syntax'; use 5.01;
1260 state $a;
1261 sort { $a <=> $b } ();
1262 EXPECT
1263 "state $a" used in sort comparison at - line 4.
1264 ########
1265 # op.c [Perl_ck_cmp]
1266 use warnings 'syntax' ;
1267 no warnings 'deprecated';
1268 @a = $[ < 5;
1269 @a = $[ > 5;
1270 @a = $[ <= 5;
1271 @a = $[ >= 5;
1272 @a = 42 < $[;
1273 @a = 42 > $[;
1274 @a = 42 <= $[;
1275 @a = 42 >= $[;
1276 use integer;
1277 @a = $[ < 5;
1278 @a = $[ > 5;
1279 @a = $[ <= 5;
1280 @a = $[ >= 5;
1281 @a = 42 < $[;
1282 @a = 42 > $[;
1283 @a = 42 <= $[;
1284 @a = 42 >= $[;
1285 no integer;
1286 @a = $[ < $5;
1287 @a = $[ > $5;
1288 @a = $[ <= $5;
1289 @a = $[ >= $5;
1290 @a = $42 < $[;
1291 @a = $42 > $[;
1292 @a = $42 <= $[;
1293 @a = $42 >= $[;
1294 use integer;
1295 @a = $[ < $5;
1296 @a = $[ > $5;
1297 @a = $[ <= $5;
1298 @a = $[ >= $5;
1299 @a = $42 < $[;
1300 @a = $42 > $[;
1301 @a = $42 <= $[;
1302 @a = $42 >= $[;
1303 EXPECT
1304 $[ used in numeric lt (<) (did you mean $] ?) at - line 4.
1305 $[ used in numeric gt (>) (did you mean $] ?) at - line 5.
1306 $[ used in numeric le (<=) (did you mean $] ?) at - line 6.
1307 $[ used in numeric ge (>=) (did you mean $] ?) at - line 7.
1308 $[ used in numeric lt (<) (did you mean $] ?) at - line 8.
1309 $[ used in numeric gt (>) (did you mean $] ?) at - line 9.
1310 $[ used in numeric le (<=) (did you mean $] ?) at - line 10.
1311 $[ used in numeric ge (>=) (did you mean $] ?) at - line 11.
1312 $[ used in numeric lt (<) (did you mean $] ?) at - line 13.
1313 $[ used in numeric gt (>) (did you mean $] ?) at - line 14.
1314 $[ used in numeric le (<=) (did you mean $] ?) at - line 15.
1315 $[ used in numeric ge (>=) (did you mean $] ?) at - line 16.
1316 $[ used in numeric lt (<) (did you mean $] ?) at - line 17.
1317 $[ used in numeric gt (>) (did you mean $] ?) at - line 18.
1318 $[ used in numeric le (<=) (did you mean $] ?) at - line 19.
1319 $[ used in numeric ge (>=) (did you mean $] ?) at - line 20.
1320 ########
1321 # op.c [Perl_ck_length]
1322 use warnings 'syntax' ;
1323 length(@a);
1324 length(%b);
1325 length(@$c);
1326 length(%$d);
1327 length($a);
1328 length(my %h);
1329 length(my @g);
1330 EXPECT
1331 length() used on @a (did you mean "scalar(@a)"?) at - line 3.
1332 length() used on %b (did you mean "scalar(keys %b)"?) at - line 4.
1333 length() used on @array (did you mean "scalar(@array)"?) at - line 5.
1334 length() used on %hash (did you mean "scalar(keys %hash)"?) at - line 6.
1335 length() used on %h (did you mean "scalar(keys %h)"?) at - line 8.
1336 length() used on @g (did you mean "scalar(@g)"?) at - line 9.
1337 ########
1338 # op.c
1339 use warnings 'syntax' ;
1340 join /---/, 'x', 'y', 'z';
1341 EXPECT
1342 /---/ should probably be written as "---" at - line 3.
1343 ########
1344 # op.c
1345 use utf8;
1346 use open qw( :utf8 :std );
1347 use warnings 'syntax' ;
1348 join /~~~/, 'x', 'y', 'z';
1349 EXPECT
1350 /~~~/ should probably be written as "~~~" at - line 5.
1351 ########
1352 # op.c [Perl_peep]
1353 use warnings 'prototype' ;
1354 fred() ; 
1355 sub fred ($$) {}
1356 no warnings 'prototype' ;
1357 joe() ; 
1358 sub joe ($$) {}
1359 EXPECT
1360 main::fred() called too early to check prototype at - line 3.
1361 ########
1362 # op.c [Perl_newATTRSUB]
1363 --FILE-- abc.pm
1364 use warnings 'void' ;
1365 BEGIN { $| = 1; print "in begin\n"; }
1366 CHECK { print "in check\n"; }
1367 INIT { print "in init\n"; }
1368 END { print "in end\n"; }
1369 print "in mainline\n";
1370 1;
1371 --FILE--
1372 use abc;
1373 delete $INC{"abc.pm"};
1374 require abc;
1375 do "abc.pm";
1376 EXPECT
1377 in begin
1378 in mainline
1379 in check
1380 in init
1381 in begin
1382 Too late to run CHECK block at abc.pm line 3.
1383 Too late to run INIT block at abc.pm line 4.
1384 in mainline
1385 in begin
1386 Too late to run CHECK block at abc.pm line 3.
1387 Too late to run INIT block at abc.pm line 4.
1388 in mainline
1389 in end
1390 in end
1391 in end
1392 ########
1393 # op.c [Perl_newATTRSUB]
1394 --FILE-- abc.pm
1395 no warnings 'void' ;
1396 BEGIN { $| = 1; print "in begin\n"; }
1397 CHECK { print "in check\n"; }
1398 INIT { print "in init\n"; }
1399 END { print "in end\n"; }
1400 print "in mainline\n";
1401 1;
1402 --FILE--
1403 BEGIN { unshift @INC, '.' }
1404 require abc;
1405 do "abc.pm";
1406 EXPECT
1407 in begin
1408 in mainline
1409 in begin
1410 in mainline
1411 in end
1412 in end
1413 ########
1414 # op.c
1415 my @x;
1416 use warnings 'syntax' ;
1417 push(@x);
1418 unshift(@x);
1419 no warnings 'syntax' ;
1420 push(@x);
1421 unshift(@x);
1422 EXPECT
1423 Useless use of push with no values at - line 4.
1424 Useless use of unshift with no values at - line 5.
1425 ########
1426 # op.c
1427 # 20020401 mjd@plover.com at suggestion of jfriedl@yahoo.com
1428 use warnings 'regexp';
1429 split /blah/g, "blah";
1430 no warnings 'regexp';
1431 split /blah/g, "blah";
1432 EXPECT
1433 Use of /g modifier is meaningless in split at - line 4.
1434 ########
1435 use feature "bitwise";
1436 $_ = $_ | $_;
1437 $_ = $_ & $_;
1438 $_ = $_ ^ $_;
1439 $_ = ~$_;
1440 $_ = $_ |. $_;
1441 $_ = $_ &. $_;
1442 $_ = $_ ^. $_;
1443 $_ = ~.$_;
1444 $_ |= $_;
1445 $_ &= $_;
1446 $_ ^= $_;
1447 $_ |.= $_;
1448 $_ &.= $_;
1449 $_ ^.= $_;
1450 use warnings "experimental::bitwise";
1451 $_ = $_ | $_;
1452 $_ = $_ & $_;
1453 $_ = $_ ^ $_;
1454 $_ = ~$_;
1455 $_ = $_ |. $_;
1456 $_ = $_ &. $_;
1457 $_ = $_ ^. $_;
1458 $_ = ~.$_;
1459 $_ |= $_;
1460 $_ &= $_;
1461 $_ ^= $_;
1462 $_ |.= $_;
1463 $_ &.= $_;
1464 $_ ^.= $_;
1465 no warnings "experimental::bitwise";
1466 $_ = $_ | $_;
1467 $_ = $_ & $_;
1468 $_ = $_ ^ $_;
1469 $_ = ~$_;
1470 $_ = $_ |. $_;
1471 $_ = $_ &. $_;
1472 $_ = $_ ^. $_;
1473 $_ = ~.$_;
1474 $_ |= $_;
1475 $_ &= $_;
1476 $_ ^= $_;
1477 $_ |.= $_;
1478 $_ &.= $_;
1479 $_ ^.= $_;
1480 EXPECT
1481 The bitwise feature is experimental at - line 2.
1482 The bitwise feature is experimental at - line 3.
1483 The bitwise feature is experimental at - line 4.
1484 The bitwise feature is experimental at - line 5.
1485 The bitwise feature is experimental at - line 6.
1486 The bitwise feature is experimental at - line 7.
1487 The bitwise feature is experimental at - line 8.
1488 The bitwise feature is experimental at - line 9.
1489 The bitwise feature is experimental at - line 10.
1490 The bitwise feature is experimental at - line 11.
1491 The bitwise feature is experimental at - line 12.
1492 The bitwise feature is experimental at - line 13.
1493 The bitwise feature is experimental at - line 14.
1494 The bitwise feature is experimental at - line 15.
1495 The bitwise feature is experimental at - line 17.
1496 The bitwise feature is experimental at - line 18.
1497 The bitwise feature is experimental at - line 19.
1498 The bitwise feature is experimental at - line 20.
1499 The bitwise feature is experimental at - line 21.
1500 The bitwise feature is experimental at - line 22.
1501 The bitwise feature is experimental at - line 23.
1502 The bitwise feature is experimental at - line 24.
1503 The bitwise feature is experimental at - line 25.
1504 The bitwise feature is experimental at - line 26.
1505 The bitwise feature is experimental at - line 27.
1506 The bitwise feature is experimental at - line 28.
1507 The bitwise feature is experimental at - line 29.
1508 The bitwise feature is experimental at - line 30.
1509 ########
1510 # op.c
1511 use warnings 'precedence';
1512 $a = $b & $c == $d;
1513 $a = $b ^ $c != $d;
1514 $a = $b | $c > $d;
1515 $a = $b < $c & $d;
1516 $a = $b >= $c ^ $d;
1517 $a = $b <= $c | $d;
1518 $a = $b <=> $c & $d;
1519 $a &= $b == $c; $a |= $b == $c; $a ^= $b == $c; # shouldn't warn
1520 {
1521  use experimental 'bitwise';
1522  $a = $b & $c == $d;
1523  $a = $b ^ $c != $d;
1524  $a = $b | $c > $d;
1525  $a = $b < $c & $d;
1526  $a = $b >= $c ^ $d;
1527  $a = $b <= $c | $d;
1528  $a = $b <=> $c & $d;
1529  $a &= $b == $c; $a |= $b == $c; $a ^= $b == $c; # shouldn't warn
1530  $a = $b &. $c == $d;
1531  $a = $b ^. $c != $d;
1532  $a = $b |. $c > $d;
1533  $a = $b < $c &. $d;
1534  $a = $b >= $c ^. $d;
1535  $a = $b <= $c |. $d;
1536  $a = $b <=> $c &. $d;
1537  $a &.= $b == $c; $a |.= $b == $c; $a ^.= $b == $c; # shouldn't warn
1538 }
1539 no warnings 'precedence';
1540 $a = $b & $c == $d;
1541 $a = $b ^ $c != $d;
1542 $a = $b | $c > $d;
1543 $a = $b < $c & $d;
1544 $a = $b >= $c ^ $d;
1545 $a = $b <= $c | $d;
1546 $a = $b <=> $c & $d;
1547 {
1548  use experimental 'bitwise';
1549  $a = $b & $c == $d;
1550  $a = $b ^ $c != $d;
1551  $a = $b | $c > $d;
1552  $a = $b < $c & $d;
1553  $a = $b >= $c ^ $d;
1554  $a = $b <= $c | $d;
1555  $a = $b <=> $c & $d;
1556  $a &= $b == $c; $a |= $b == $c; $a ^= $b == $c; # shouldn't warn
1557  $a = $b &. $c == $d;
1558  $a = $b ^. $c != $d;
1559  $a = $b |. $c > $d;
1560  $a = $b < $c &. $d;
1561  $a = $b >= $c ^. $d;
1562  $a = $b <= $c |. $d;
1563  $a = $b <=> $c &. $d;
1564  $a &.= $b == $c; $a |.= $b == $c; $a ^.= $b == $c; # shouldn't warn
1565 }
1566 EXPECT
1567 Possible precedence problem on bitwise & operator at - line 3.
1568 Possible precedence problem on bitwise ^ operator at - line 4.
1569 Possible precedence problem on bitwise | operator at - line 5.
1570 Possible precedence problem on bitwise & operator at - line 6.
1571 Possible precedence problem on bitwise ^ operator at - line 7.
1572 Possible precedence problem on bitwise | operator at - line 8.
1573 Possible precedence problem on bitwise & operator at - line 9.
1574 Possible precedence problem on bitwise & operator at - line 13.
1575 Possible precedence problem on bitwise ^ operator at - line 14.
1576 Possible precedence problem on bitwise | operator at - line 15.
1577 Possible precedence problem on bitwise & operator at - line 16.
1578 Possible precedence problem on bitwise ^ operator at - line 17.
1579 Possible precedence problem on bitwise | operator at - line 18.
1580 Possible precedence problem on bitwise & operator at - line 19.
1581 Possible precedence problem on bitwise &. operator at - line 21.
1582 Possible precedence problem on bitwise ^. operator at - line 22.
1583 Possible precedence problem on bitwise |. operator at - line 23.
1584 Possible precedence problem on bitwise &. operator at - line 24.
1585 Possible precedence problem on bitwise ^. operator at - line 25.
1586 Possible precedence problem on bitwise |. operator at - line 26.
1587 Possible precedence problem on bitwise &. operator at - line 27.
1588 ########
1589 # op.c
1590 use integer;
1591 use warnings 'precedence';
1592 $a = $b & $c == $d;
1593 $a = $b ^ $c != $d;
1594 $a = $b | $c > $d;
1595 $a = $b < $c & $d;
1596 $a = $b >= $c ^ $d;
1597 $a = $b <= $c | $d;
1598 $a = $b <=> $c & $d;
1599 no warnings 'precedence';
1600 $a = $b & $c == $d;
1601 $a = $b ^ $c != $d;
1602 $a = $b | $c > $d;
1603 $a = $b < $c & $d;
1604 $a = $b >= $c ^ $d;
1605 $a = $b <= $c | $d;
1606 $a = $b <=> $c & $d;
1607 EXPECT
1608 Possible precedence problem on bitwise & operator at - line 4.
1609 Possible precedence problem on bitwise ^ operator at - line 5.
1610 Possible precedence problem on bitwise | operator at - line 6.
1611 Possible precedence problem on bitwise & operator at - line 7.
1612 Possible precedence problem on bitwise ^ operator at - line 8.
1613 Possible precedence problem on bitwise | operator at - line 9.
1614 Possible precedence problem on bitwise & operator at - line 10.
1615 ########
1616 # op.c
1617
1618 # ok    => local() has desired effect;
1619 # ignore=> local() silently ignored
1620
1621 use warnings 'syntax';
1622
1623 local(undef);           # OP_UNDEF              ignore
1624 sub lval : lvalue {};
1625 local(lval());          # OP_ENTERSUB
1626 local($x **= 1);        # OP_POW
1627 local($x *=  1);        # OP_MULTIPLY
1628 local($x /=  1);        # OP_DIVIDE
1629 local($x %=  1);        # OP_MODULO
1630 local($x x=  1);        # OP_REPEAT
1631 local($x +=  1);        # OP_ADD
1632 local($x -=  1);        # OP_SUBTRACT
1633 local($x .=  1);        # OP_CONCAT
1634 local($x <<= 1);        # OP_LEFT_SHIFT
1635 local($x >>= 1);        # OP_RIGHT_SHIFT
1636 local($x &=  1);        # OP_BIT_AND
1637 local($x ^=  1);        # OP_BIT_XOR
1638 local($x |=  1);        # OP_BIT_OR
1639 {
1640     use integer;
1641     local($x *= 1);     # OP_I_MULTIPLY
1642     local($x /= 1);     # OP_I_DIVIDE
1643     local($x %= 1);     # OP_I_MODULO
1644     local($x += 1);     # OP_I_ADD
1645     local($x -= 1);     # OP_I_SUBTRACT
1646 }
1647 local($x?$y:$z) = 1;    # OP_COND_EXPR          ok
1648 # these two are fatal run-time errors instead
1649 #local(@$a);            # OP_RV2AV              ok
1650 #local(%$a);            # OP_RV2HV              ok
1651 local(*a);              # OP_RV2GV              ok
1652 local(@a[1,2]);         # OP_ASLICE             ok
1653 local(@a{1,2});         # OP_HSLICE             ok
1654 local(@a = (1,2));      # OP_AASSIGN
1655 local($$x);             # OP_RV2SV              ok
1656 local($#a);             # OP_AV2ARYLEN
1657 local($x =   1);        # OP_SASSIGN
1658 local($x &&= 1);        # OP_ANDASSIGN
1659 local($x ||= 1);        # OP_ORASSIGN
1660 local($x //= 1);        # OP_DORASSIGN
1661 local($a[0]);           # OP_AELEMFAST          ok
1662
1663 local(substr($x,0,1));  # OP_SUBSTR
1664 local(pos($x));         # OP_POS
1665 local(vec($x,0,1));     # OP_VEC
1666 local($a[$b]);          # OP_AELEM              ok
1667 local($a{$b});          # OP_HELEM              ok
1668
1669 no warnings 'syntax';
1670 EXPECT
1671 Useless localization of subroutine entry at - line 10.
1672 Useless localization of exponentiation (**) at - line 11.
1673 Useless localization of multiplication (*) at - line 12.
1674 Useless localization of division (/) at - line 13.
1675 Useless localization of modulus (%) at - line 14.
1676 Useless localization of repeat (x) at - line 15.
1677 Useless localization of addition (+) at - line 16.
1678 Useless localization of subtraction (-) at - line 17.
1679 Useless localization of concatenation (.) or string at - line 18.
1680 Useless localization of left bitshift (<<) at - line 19.
1681 Useless localization of right bitshift (>>) at - line 20.
1682 Useless localization of bitwise and (&) at - line 21.
1683 Useless localization of bitwise xor (^) at - line 22.
1684 Useless localization of bitwise or (|) at - line 23.
1685 Useless localization of integer multiplication (*) at - line 26.
1686 Useless localization of integer division (/) at - line 27.
1687 Useless localization of integer modulus (%) at - line 28.
1688 Useless localization of integer addition (+) at - line 29.
1689 Useless localization of integer subtraction (-) at - line 30.
1690 Useless localization of list assignment at - line 39.
1691 Useless localization of array length at - line 41.
1692 Useless localization of scalar assignment at - line 42.
1693 Useless localization of logical and assignment (&&=) at - line 43.
1694 Useless localization of logical or assignment (||=) at - line 44.
1695 Useless localization of defined or assignment (//=) at - line 45.
1696 Useless localization of substr at - line 48.
1697 Useless localization of match position at - line 49.
1698 Useless localization of vec at - line 50.
1699 ########
1700 # op.c
1701 my $x1 if 0;
1702 my @x2 if 0;
1703 my %x3 if 0;
1704 my ($x4) if 0;
1705 my ($x5,@x6, %x7) if 0;
1706 0 && my $z1;
1707 0 && my (%z2);
1708 # these shouldn't warn
1709 our $x if 0;
1710 our $x unless 0;
1711 if (0) { my $w1 }
1712 if (my $w2) { $a=1 }
1713 if ($a && (my $w3 = 1)) {$a = 2}
1714
1715 EXPECT
1716 Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 2.
1717 Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 3.
1718 Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 4.
1719 Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 5.
1720 Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 6.
1721 Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 7.
1722 Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 8.
1723 ########
1724 # op.c
1725 $[ = 1;
1726 ($[) = 1;
1727 use warnings 'deprecated';
1728 $[ = 2;
1729 ($[) = 2;
1730 no warnings 'deprecated';
1731 $[ = 3;
1732 ($[) = 3;
1733 EXPECT
1734 Use of assignment to $[ is deprecated at - line 2.
1735 Use of assignment to $[ is deprecated at - line 3.
1736 Use of assignment to $[ is deprecated at - line 5.
1737 Use of assignment to $[ is deprecated at - line 6.
1738 ########
1739 # op.c
1740 use warnings 'void';
1741 @x = split /y/, "z";
1742 $x = split /y/, "z";
1743      split /y/, "z";
1744 no warnings 'void';
1745 @x = split /y/, "z";
1746 $x = split /y/, "z";
1747      split /y/, "z";
1748 EXPECT
1749 Useless use of split in void context at - line 5.
1750 ########
1751 # op.c
1752 use warnings 'redefine' ;
1753 use utf8;
1754 use open qw( :utf8 :std );
1755 sub frèd {}
1756 sub frèd {}
1757 no warnings 'redefine' ;
1758 sub frèd {}
1759 EXPECT
1760 Subroutine frèd redefined at - line 6.
1761 ########
1762 # op.c
1763 use warnings 'redefine' ;
1764 use utf8;
1765 use open qw( :utf8 :std );
1766 sub frèd () { 1 }
1767 sub frèd () { 1 }
1768 no warnings 'redefine' ;
1769 sub frèd () { 1 }
1770 EXPECT
1771 Constant subroutine frèd redefined at - line 6.
1772 ########
1773 # op.c
1774 use utf8;
1775 use open qw( :utf8 :std );
1776 sub frèd () { 1 }
1777 sub frèd () { 2 }
1778 EXPECT
1779 Constant subroutine frèd redefined at - line 5.
1780 ########
1781 # op.c
1782 use utf8;
1783 use open qw( :utf8 :std );
1784 sub frèd () { 1 }
1785 *frèd = sub () { 2 };
1786 EXPECT
1787 Constant subroutine main::frèd redefined at - line 5.
1788 ########
1789 # op.c
1790 use warnings 'redefine' ;
1791 use utf8;
1792 use open qw( :utf8 :std );
1793 sub ᚠርƊ {}
1794 sub ᚠርƊ {}
1795 no warnings 'redefine' ;
1796 sub ᚠርƊ {}
1797 EXPECT
1798 Subroutine ᚠርƊ redefined at - line 6.
1799 ########
1800 # op.c
1801 use warnings 'redefine' ;
1802 use utf8;
1803 use open qw( :utf8 :std );
1804 sub ᚠርƊ () { 1 }
1805 sub ᚠርƊ () { 1 }
1806 no warnings 'redefine' ;
1807 sub ᚠርƊ () { 1 }
1808 EXPECT
1809 Constant subroutine ᚠርƊ redefined at - line 6.
1810 ########
1811 # op.c
1812 use utf8;
1813 use open qw( :utf8 :std );
1814 sub ᚠርƊ () { 1 }
1815 sub ᚠርƊ () { 2 }
1816 EXPECT
1817 Constant subroutine ᚠርƊ redefined at - line 5.
1818 ########
1819 # op.c
1820 use utf8;
1821 use open qw( :utf8 :std );
1822 sub ᚠርƊ () { 1 }
1823 *ᚠርƊ = sub () { 2 };
1824 EXPECT
1825 Constant subroutine main::ᚠርƊ redefined at - line 5.
1826 ########
1827 # OPTION regex
1828 sub DynaLoader::dl_error {};
1829 use warnings;
1830 # We're testing that the warnings report the same line number:
1831 eval <<'EOC' or die $@;
1832 {
1833     DynaLoader::boot_DynaLoader("DynaLoader");
1834 }
1835 EOC
1836 eval <<'EOC' or die $@;
1837 BEGIN {
1838     DynaLoader::boot_DynaLoader("DynaLoader");
1839 }
1840 1
1841 EOC
1842 EXPECT
1843 OPTION regex
1844 \ASubroutine DynaLoader::dl_error redefined at \(eval 1\) line 2\.
1845 ?(?s).*
1846 Subroutine DynaLoader::dl_error redefined at \(eval 2\) line 2\.
1847 ########
1848 # op.c
1849 use warnings;
1850 sub do_warn_1  { return $a or $b; }
1851 sub do_warn_2  { return $a and $b; }
1852 sub do_warn_3  { return $a xor $b; }
1853 sub do_warn_4  { die $a or $b; }
1854 sub do_warn_5  { die $a and $b; }
1855 sub do_warn_6  { die $a xor $b; }
1856 sub do_warn_7  { exit $a or $b; }
1857 sub do_warn_8  { exit $a and $b; }
1858 sub do_warn_9  { exit $a xor $b; }
1859
1860 # Since exit is an unary operator, it is even stronger than
1861 # || and &&.
1862 sub do_warn_10 { exit $a || $b; }
1863 sub do_warn_11 { exit $a && $b; }
1864
1865 sub do_warn_12 { goto $a or $b; }
1866 sub do_warn_13 { goto $a and $b; }
1867 sub do_warn_14 { goto $a xor $b; }
1868 sub do_warn_15 { next $a or $b while(1);  }
1869 sub do_warn_16 { next $a and $b while(1); }
1870 sub do_warn_17 { next $a xor $b while(1); }
1871 sub do_warn_18 { last $a or $b while(1);  }
1872 sub do_warn_19 { last $a and $b while(1); }
1873 sub do_warn_20 { last $a xor $b while(1); }
1874 sub do_warn_21 { redo $a or $b while(1); }
1875 sub do_warn_22 { redo $a and $b while(1); }
1876 sub do_warn_23 { redo $a xor $b while(1); }
1877 # These get re-written to "(return/die $a) and $b"
1878 sub do_warn_24 { $b if return $a; }
1879 sub do_warn_25 { $b if die $a; }
1880 EXPECT
1881 Possible precedence issue with control flow operator at - line 3.
1882 Possible precedence issue with control flow operator at - line 4.
1883 Possible precedence issue with control flow operator at - line 5.
1884 Possible precedence issue with control flow operator at - line 6.
1885 Possible precedence issue with control flow operator at - line 7.
1886 Possible precedence issue with control flow operator at - line 8.
1887 Possible precedence issue with control flow operator at - line 9.
1888 Possible precedence issue with control flow operator at - line 10.
1889 Possible precedence issue with control flow operator at - line 11.
1890 Possible precedence issue with control flow operator at - line 15.
1891 Possible precedence issue with control flow operator at - line 16.
1892 Possible precedence issue with control flow operator at - line 18.
1893 Possible precedence issue with control flow operator at - line 19.
1894 Possible precedence issue with control flow operator at - line 20.
1895 Possible precedence issue with control flow operator at - line 21.
1896 Possible precedence issue with control flow operator at - line 22.
1897 Possible precedence issue with control flow operator at - line 23.
1898 Possible precedence issue with control flow operator at - line 24.
1899 Possible precedence issue with control flow operator at - line 25.
1900 Possible precedence issue with control flow operator at - line 26.
1901 Possible precedence issue with control flow operator at - line 27.
1902 Possible precedence issue with control flow operator at - line 28.
1903 Possible precedence issue with control flow operator at - line 29.
1904 Possible precedence issue with control flow operator at - line 31.
1905 Possible precedence issue with control flow operator at - line 32.
1906 ########
1907 # op.c
1908 #  (same as above, except these should not warn)
1909 use constant FEATURE => 1;
1910 use constant MISSING_FEATURE => 0;
1911
1912 sub dont_warn_1  { MISSING_FEATURE and return or dont_warn_3(); }
1913 sub dont_warn_2  { FEATURE || return and dont_warn_3(); }
1914 sub dont_warn_3  { not FEATURE and return or dont_warn_3(); }
1915 sub dont_warn_4  { !MISSING_FEATURE || return and dont_warn_3(); }
1916 sub dont_warn_5  { MISSING_FEATURE and die or dont_warn_3(); }
1917 sub dont_warn_6  { FEATURE || die and dont_warn_3(); }
1918 sub dont_warn_7  { not FEATURE and die or dont_warn_3(); }
1919 sub dont_warn_8  { !MISSING_FEATURE || die and dont_warn_3(); }
1920 sub dont_warn_9  { MISSING_FEATURE and goto $a or dont_warn_3(); }
1921 sub dont_warn_10 { FEATURE || goto $a and dont_warn_3(); }
1922 sub dont_warn_11 { not FEATURE and goto $a or dont_warn_3(); }
1923 sub dont_warn_12 { !MISSING_FEATURE || goto $a and dont_warn_3(); }
1924
1925 sub dont_warn_13 { MISSING_FEATURE and exit $a or dont_warn_3(); }
1926 sub dont_warn_14 { FEATURE || exit $a and dont_warn_3(); }
1927 sub dont_warn_15 { not FEATURE and exit $a or dont_warn_3(); }
1928 sub dont_warn_16 { !MISSING_FEATURE || exit $a and dont_warn_3(); }
1929
1930 sub dont_warn_17 { MISSING_FEATURE and next or dont_warn_3() while(1); }
1931 sub dont_warn_18 { FEATURE || next and dont_warn_3() while(1); }
1932 sub dont_warn_19 { not FEATURE and next or dont_warn_3() while(1); }
1933 sub dont_warn_20 { !MISSING_FEATURE || next and dont_warn_3() while(1); }
1934 sub dont_warn_21 { MISSING_FEATURE and redo or dont_warn_3() while(1); }
1935 sub dont_warn_22 { FEATURE || redo and dont_warn_3() while(1); }
1936 sub dont_warn_23 { not FEATURE and redo or dont_warn_3() while(1); }
1937 sub dont_warn_24 { !MISSING_FEATURE || redo and dont_warn_3() while(1); }
1938 sub dont_warn_25 { MISSING_FEATURE and last or dont_warn_3() while(1); }
1939 sub dont_warn_26 { FEATURE || last and dont_warn_3() while(1); }
1940 sub dont_warn_27 { not FEATURE and last or dont_warn_3() while(1); }
1941 sub dont_warn_28 { !MISSING_FEATURE || last and dont_warn_3() while(1); }
1942
1943 # These are weird, but at least not ambiguous.
1944 sub dont_warn_29 { return ($a or $b); }
1945 sub dont_warn_30 { return ($a and $b); }
1946 sub dont_warn_31 { return ($a xor $b); }
1947 sub dont_warn_32 { die ($a or $b); }
1948 sub dont_warn_33 { die ($a and $b); }
1949 sub dont_warn_34 { die ($a xor $b); }
1950 sub dont_warn_35 { goto ($a or $b); }
1951 sub dont_warn_36 { goto ($a and $b); }
1952 sub dont_warn_37 { goto ($a xor $b); }
1953 sub dont_warn_38 { next ($a or $b) while(1);  }
1954 sub dont_warn_39 { next ($a and $b) while(1); }
1955 sub dont_warn_40 { next ($a xor $b) while(1); }
1956 sub dont_warn_41 { last ($a or $b) while(1);  }
1957 sub dont_warn_42 { last ($a and $b) while(1); }
1958 sub dont_warn_43 { last ($a xor $b) while(1); }
1959 sub dont_warn_44 { redo ($a or $b) while(1);  }
1960 sub dont_warn_45 { redo ($a and $b) while(1); }
1961 sub dont_warn_46 { redo ($a xor $b) while(1); }
1962 EXPECT
1963 ########
1964 use feature "signatures";
1965 sub aaa { 2 }
1966 sub bbb ($a) { 4 }
1967 $aaa = sub { 2 };
1968 $bbb = sub ($a) { 4 };
1969 EXPECT
1970 The signatures feature is experimental at - line 3.
1971 The signatures feature is experimental at - line 5.
1972 ########
1973 no warnings "experimental::signatures";
1974 use feature "signatures";
1975 sub aaa { 2 }
1976 sub bbb ($a) { 4 }
1977 $aaa = sub { 2 };
1978 $bbb = sub ($a) { 4 };
1979 EXPECT
1980 ########
1981 use warnings 'numeric';
1982 my $c = -4.5;
1983 my $a = "y" x $c;
1984 my $b = "y" x -3;
1985 no warnings 'numeric';
1986 my $d = "y" x $c;
1987 my $e = "y" x -3;
1988 no warnings 'numeric';
1989 EXPECT
1990 Negative repeat count does nothing at - line 3.
1991 Negative repeat count does nothing at - line 4.
1992 ########
1993 use Config;
1994 my $non_ieee_fp = ($Config{doublekind} == 9 ||
1995                    $Config{doublekind} == 10 ||
1996                    $Config{doublekind} == 11);
1997 if ($non_ieee_fp) {
1998     print <<EOM ;
1999 SKIPPED
2000 # No inf/nan support
2001 EOM
2002     exit ;
2003 }
2004 my $a = "inf" + 0;
2005 my $b = -$a;
2006 my $c = "nan" + 0;
2007 use warnings 'numeric';
2008 my $x = "x" x $a;
2009 my $y = "y" x $b;
2010 my $z = "z" x $c;
2011 no warnings 'numeric';
2012 my $x = "x" x $a;
2013 my $y = "y" x $b;
2014 my $z = "z" x $c;
2015 no warnings 'numeric';
2016 EXPECT
2017 Non-finite repeat count does nothing at - line 16.
2018 Non-finite repeat count does nothing at - line 17.
2019 Non-finite repeat count does nothing at - line 18.
2020 ########
2021 # NAME warn on stat @array
2022 @foo = ("op/stat.t");
2023 stat @foo;
2024 my @bar = @foo;
2025 stat @bar;
2026 my $ref = \@foo;
2027 stat @$ref;
2028 use warnings 'syntax';
2029 stat @foo;
2030 stat @bar;
2031 stat @$ref;
2032 EXPECT
2033 Array passed to stat will be coerced to a scalar (did you want stat $foo[0]?) at - line 8.
2034 Array passed to stat will be coerced to a scalar (did you want stat $bar[0]?) at - line 9.
2035 Array passed to stat will be coerced to a scalar at - line 10.
2036
2037 ########
2038 # NAME barewords and conditionals near constant folding
2039 use warnings;
2040 my $x1 = !a || !b; # no "in conditional" warnings
2041 my $x2 = !A || !B; # warning-free, because upper-case won't clash
2042 EXPECT
2043 Unquoted string "a" may clash with future reserved word at - line 2.
2044 Unquoted string "b" may clash with future reserved word at - line 2.
2045 ########
2046 # RT #6870: Odd parsing of do...for...
2047 # This was really more a tokenizer bug, but it manifests as spurious warnings
2048 use warnings;
2049 no warnings 'reserved';
2050 $a=do xa for ax;
2051 do "xa" for ax;
2052 do xa for ax;
2053 do xa for "ax";
2054 do xa for sin(1);
2055 do xa for (sin(1));
2056 do xa for "sin";
2057 do xa for qq(sin);
2058 do xa for my $a;
2059 do xa for my @a;
2060 EXPECT
2061 ########
2062 # TODO [perl #125493
2063 use warnings;
2064 $_="3.14159";
2065 tr/0-9/\x{6F0}-\x{6F9}/;
2066 EXPECT