This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: S_checkcomma, "No comma allowed after %s" cleanup
[perl5.git] / t / lib / warnings / toke
1 toke.c  AOK
2
3     we seem to have lost a few ambiguous warnings!!
4
5  
6                 $a = <<;
7                 Use of comma-less variable list is deprecated 
8                 (called 3 times via depcom)
9
10      \1 better written as $1 
11         use warnings 'syntax' ;
12         s/(abc)/\1/;
13  
14      warn(warn_nosemi) 
15      Semicolon seems to be missing
16         $a = 1
17         &time ;
18
19
20      Reversed %c= operator 
21         my $a =+ 2 ;
22         $a =- 2 ;
23         $a =* 2 ;
24         $a =% 2 ;
25         $a =& 2 ;
26         $a =. 2 ;
27         $a =^ 2 ;
28         $a =| 2 ;
29         $a =< 2 ;
30         $a =/ 2 ;
31
32      Multidimensional syntax %.*s not supported 
33         my $a = $a[1,2] ;
34
35      You need to quote \"%s\"" 
36         sub fred {} ; $SIG{TERM} = fred;
37
38      Scalar value %.*s better written as $%.*s" 
39         @a[3] = 2;
40         @a{3} = 2;
41
42      Can't use \\%c to mean $%c in expression 
43         $_ = "ab" ; s/(ab)/\1/e;
44
45      Unquoted string "abc" may clash with future reserved word at - line 3.
46      warn(warn_reserved 
47         $a = abc;
48
49      Possible attempt to separate words with commas 
50         @a = qw(a, b, c) ;
51
52      Possible attempt to put comments in qw() list 
53         @a = qw(a b # c) ;
54
55      %s (...) interpreted as function 
56         print ("")
57         printf ("")
58         sort ("")
59
60      Ambiguous use of %c{%s%s} resolved to %c%s%s 
61         $a = ${time[2]}
62         $a = ${time{2}}
63
64
65      Ambiguous use of %c{%s} resolved to %c%s
66         $a = ${time}
67         sub fred {} $a = ${fred}
68
69      Misplaced _ in number 
70         $a = 1_2;
71         $a = 1_2345_6;
72
73     Bareword \"%s\" refers to nonexistent package
74         $a = FRED:: ;
75
76     Ambiguous call resolved as CORE::%s(), qualify as such or use &
77         sub time {} 
78         my $a = time()
79
80     Unrecognized escape \\%c passed through
81         $a = "\m" ;
82
83     Useless use of \\E.
84         $a = "abcd\E" ;
85
86     %s number > %s non-portable
87         my $a =  0b011111111111111111111111111111110 ;
88         $a =  0b011111111111111111111111111111111 ;
89         $a =  0b111111111111111111111111111111111 ;
90         $a =  0x0fffffffe ;
91         $a =  0x0ffffffff ;
92         $a =  0x1ffffffff ;
93         $a =  0037777777776 ;
94         $a =  0037777777777 ;
95         $a =  0047777777777 ;
96
97     Integer overflow in binary number
98         my $a =  0b011111111111111111111111111111110 ;
99         $a =  0b011111111111111111111111111111111 ;
100         $a =  0b111111111111111111111111111111111 ;
101         $a =  0x0fffffffe ;
102         $a =  0x0ffffffff ;
103         $a =  0x1ffffffff ;
104         $a =  0037777777776 ;
105         $a =  0037777777777 ;
106         $a =  0047777777777 ;
107
108     dump() better written as CORE::dump()
109
110     Use of /c modifier is meaningless without /g     
111
112     Use of /c modifier is meaningless in s///
113
114     Mandatory Warnings
115     ------------------
116     Use of "%s" without parentheses is ambiguous        [check_uni]
117         rand + 4 
118
119     Ambiguous use of -%s resolved as -&%s()             [yylex]
120         sub fred {} ; - fred ;
121
122     Precedence problem: open %.*s should be open(%.*s)  [yylex]
123         open FOO || die;
124
125     Operator or semicolon missing before %c%s           [yylex]
126     Ambiguous use of %c resolved as operator %c
127         *foo *foo
128
129 __END__
130 # toke.c 
131 format STDOUT =
132 @<<<  @|||  @>>>  @>>>
133 $a    $b    "abc" 'def'
134 .
135 no warnings 'deprecated' ;
136 format STDOUT =
137 @<<<  @|||  @>>>  @>>>
138 $a    $b    "abc" 'def'
139 .
140 EXPECT
141 Use of comma-less variable list is deprecated at - line 4.
142 Use of comma-less variable list is deprecated at - line 4.
143 Use of comma-less variable list is deprecated at - line 4.
144 ########
145 # toke.c
146 $a =~ m/$foo/sand $bar;
147 $a =~ s/$foo/fool/sand $bar;
148 $a = <<;
149
150 no warnings 'deprecated' ;
151 $a =~ m/$foo/sand $bar;
152 $a =~ s/$foo/fool/sand $bar;
153 $a = <<;
154
155 EXPECT
156 Having no space between pattern and following word is deprecated at - line 2.
157 Having no space between pattern and following word is deprecated at - line 3.
158 Use of bare << to mean <<"" is deprecated at - line 4.
159 ########
160 # toke.c
161 use warnings 'syntax' ;
162 s/(abc)/\1/;
163 no warnings 'syntax' ;
164 s/(abc)/\1/;
165 EXPECT
166 \1 better written as $1 at - line 3.
167 ########
168 # toke.c
169 use warnings 'semicolon' ;
170 $a = 1
171 &time ;
172 no warnings 'semicolon' ;
173 $a = 1
174 &time ;
175 EXPECT
176 Semicolon seems to be missing at - line 3.
177 ########
178 # toke.c
179 use warnings 'syntax' ;
180 my $a =+ 2 ;
181 $a =- 2 ;
182 $a =* 2 ;
183 $a =% 2 ;
184 $a =& 2 ;
185 $a =. 2 ;
186 $a =^ 2 ;
187 $a =| 2 ;
188 $a =< 2 ;
189 $a =/ 2 ;
190 EXPECT
191 Reversed += operator at - line 3.
192 Reversed -= operator at - line 4.
193 Reversed *= operator at - line 5.
194 Reversed %= operator at - line 6.
195 Reversed &= operator at - line 7.
196 Reversed .= operator at - line 8.
197 Reversed ^= operator at - line 9.
198 Reversed |= operator at - line 10.
199 Reversed <= operator at - line 11.
200 syntax error at - line 8, near "=."
201 syntax error at - line 9, near "=^"
202 syntax error at - line 10, near "=|"
203 Unterminated <> operator at - line 11.
204 ########
205 # toke.c
206 no warnings 'syntax' ;
207 my $a =+ 2 ;
208 $a =- 2 ;
209 $a =* 2 ;
210 $a =% 2 ;
211 $a =& 2 ;
212 $a =. 2 ;
213 $a =^ 2 ;
214 $a =| 2 ;
215 $a =< 2 ;
216 $a =/ 2 ;
217 EXPECT
218 syntax error at - line 8, near "=."
219 syntax error at - line 9, near "=^"
220 syntax error at - line 10, near "=|"
221 Unterminated <> operator at - line 11.
222 ########
223 # toke.c
224 use warnings 'syntax' ;
225 my $a = $a[1,2] ;
226 no warnings 'syntax' ;
227 my $a = $a[1,2] ;
228 EXPECT
229 Multidimensional syntax $a[1,2] not supported at - line 3.
230 ########
231 # toke.c
232 use warnings 'syntax' ;
233 sub fred {} ; $SIG{TERM} = fred;
234 no warnings 'syntax' ;
235 $SIG{TERM} = fred;
236 EXPECT
237 You need to quote "fred" at - line 3.
238 ########
239 # toke.c
240 use utf8;
241 use open qw( :utf8 :std );
242 use warnings 'syntax' ;
243 sub frèd {} ; $SIG{TERM} = frèd;
244 no warnings 'syntax' ;
245 $SIG{TERM} = frèd;
246 EXPECT
247 You need to quote "frèd" at - line 5.
248 ########
249 # toke.c
250 use utf8;
251 use open qw( :utf8 :std );
252 use warnings 'syntax' ;
253 sub ふれど {} ; $SIG{TERM} = ふれど;
254 no warnings 'syntax' ;
255 $SIG{TERM} = ふれど;
256 EXPECT
257 You need to quote "ふれど" at - line 5.
258 ########
259 # toke.c
260 use warnings 'syntax' ;
261 @a[3] = 2;
262 @a{3} = 2;
263 no warnings 'syntax' ;
264 @a[3] = 2;
265 @a{3} = 2;
266 EXPECT
267 Scalar value @a[3] better written as $a[3] at - line 3.
268 Scalar value @a{3} better written as $a{3} at - line 4.
269 ########
270 # toke.c
271 use utf8;
272 use open qw( :utf8 :std );
273 use warnings 'syntax' ;
274 @à[3] = 2;
275 @à{3} = 2;
276 no warnings 'syntax' ;
277 @à[3] = 2;
278 @à{3} = 2;
279 EXPECT
280 Scalar value @à[3] better written as $à[3] at - line 5.
281 Scalar value @à{3} better written as $à{3} at - line 6.
282 ########
283 # toke.c
284 use utf8;
285 use open qw( :utf8 :std );
286 use warnings 'syntax' ;
287 @ぁ[3] = 2;
288 @ぁ{3} = 2;
289 no warnings 'syntax' ;
290 @ぁ[3] = 2;
291 @ぁ{3} = 2;
292 EXPECT
293 Scalar value @ぁ[3] better written as $ぁ[3] at - line 5.
294 Scalar value @ぁ{3} better written as $ぁ{3} at - line 6.
295 ########
296 # toke.c
297 use warnings 'syntax' ;
298 $_ = "ab" ; 
299 s/(ab)/\1/e;
300 no warnings 'syntax' ;
301 $_ = "ab" ; 
302 s/(ab)/\1/e;
303 EXPECT
304 Can't use \1 to mean $1 in expression at - line 4.
305 ########
306 # toke.c
307 use warnings 'reserved' ;
308 $a = abc;
309 $a = { def
310
311 => 1 };
312 no warnings 'reserved' ;
313 $a = abc;
314 EXPECT
315 Unquoted string "abc" may clash with future reserved word at - line 3.
316 ########
317 # toke.c
318 use warnings 'qw' ;
319 @a = qw(a, b, c) ;
320 no warnings 'qw' ;
321 @a = qw(a, b, c) ;
322 EXPECT
323 Possible attempt to separate words with commas at - line 3.
324 ########
325 # toke.c
326 use warnings 'qw' ;
327 @a = qw(a b c # #) ;
328 no warnings 'qw' ;
329 @a = qw(a b c # #) ;
330 EXPECT
331 Possible attempt to put comments in qw() list at - line 3.
332 ########
333 # toke.c
334 use warnings 'qw' ;
335 @a = qw(a, b, c # #) ;
336 no warnings 'qw' ;
337 @a = qw(a, b, c # #) ;
338 EXPECT
339 Possible attempt to separate words with commas at - line 3.
340 Possible attempt to put comments in qw() list at - line 3.
341 ########
342 # toke.c
343 use warnings 'syntax' ;
344 print ("");
345 print ("") and $x = 1;
346 print ("") or die;
347 print ("") // die;
348 print (1+2) * 3 if 0; # only this one should warn
349 print (1+2) if 0;
350 EXPECT
351 print (...) interpreted as function at - line 7.
352 ########
353 # toke.c
354 no warnings 'syntax' ;
355 print ("")
356 EXPECT
357
358 ########
359 # toke.c
360 use warnings 'syntax' ;
361 printf ("");
362 printf ("") . '';
363 EXPECT
364 printf (...) interpreted as function at - line 4.
365 ########
366 # toke.c
367 no warnings 'syntax' ;
368 printf ("")
369 EXPECT
370
371 ########
372 # toke.c
373 use warnings 'syntax' ;
374 sort ("");
375 sort ("") . '';
376 EXPECT
377 sort (...) interpreted as function at - line 4.
378 ########
379 # toke.c
380 no warnings 'syntax' ;
381 sort ("")
382 EXPECT
383
384 ########
385 # toke.c
386 use warnings 'ambiguous' ;
387 $a = ${time[2]};
388 no warnings 'ambiguous' ;
389 $a = ${time[2]};
390 EXPECT
391 Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
392 ########
393 # toke.c
394 use warnings 'ambiguous' ;
395 $a = ${time{2}};
396 EXPECT
397 Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
398 ########
399 # toke.c
400 no warnings 'ambiguous' ;
401 $a = ${time{2}};
402 EXPECT
403
404 ########
405 # toke.c
406 use warnings 'ambiguous' ;
407 $a = ${time} ;
408 no warnings 'ambiguous' ;
409 $a = ${time} ;
410 EXPECT
411 Ambiguous use of ${time} resolved to $time at - line 3.
412 ########
413 # toke.c
414 use warnings 'ambiguous' ;
415 sub fred {}
416 $a = ${fred} ;
417 no warnings 'ambiguous' ;
418 $a = ${fred} ;
419 EXPECT
420 Ambiguous use of ${fred} resolved to $fred at - line 4.
421 ########
422 # toke.c
423 use warnings 'syntax' ;
424 $a = _123; print "$a\n";                #( 3    string)
425 $a = 1_23; print "$a\n";
426 $a = 12_3; print "$a\n";
427 $a = 123_; print "$a\n";                #  6
428 $a = _+123; print "$a\n";               #  7    string)
429 $a = +_123; print "$a\n";               #( 8    string)
430 $a = +1_23; print "$a\n";
431 $a = +12_3; print "$a\n";
432 $a = +123_; print "$a\n";               # 11
433 $a = _-123; print "$a\n";               #(12    string)
434 $a = -_123; print "$a\n";               #(13    string)
435 $a = -1_23; print "$a\n";
436 $a = -12_3; print "$a\n";
437 $a = -123_; print "$a\n";               # 16
438 $a = 123._456; print "$a\n";            # 17
439 $a = 123.4_56; print "$a\n";
440 $a = 123.45_6; print "$a\n";
441 $a = 123.456_; print "$a\n";            # 20
442 $a = +123._456; print "$a\n";           # 21
443 $a = +123.4_56; print "$a\n";   
444 $a = +123.45_6; print "$a\n";   
445 $a = +123.456_; print "$a\n";           # 24
446 $a = -123._456; print "$a\n";           # 25
447 $a = -123.4_56; print "$a\n";   
448 $a = -123.45_6; print "$a\n";
449 $a = -123.456_; print "$a\n";           # 28
450 $a = 123.456E_12; printf("%.0f\n", $a); # 29
451 $a = 123.456E1_2; printf("%.0f\n", $a);
452 $a = 123.456E12_; printf("%.0f\n", $a); # 31
453 $a = 123.456E_+12; printf("%.0f\n", $a);        # 32
454 $a = 123.456E+_12; printf("%.0f\n", $a);        # 33
455 $a = 123.456E+1_2; printf("%.0f\n", $a);
456 $a = 123.456E+12_; printf("%.0f\n", $a);        # 35
457 $a = 123.456E_-12; print "$a\n";        # 36
458 $a = 123.456E-_12; print "$a\n";        # 37
459 $a = 123.456E-1_2; print "$a\n";
460 $a = 123.456E-12_; print "$a\n";        # 39
461 $a = 1__23; print "$a\n";               # 40
462 $a = 12.3__4; print "$a\n";             # 41
463 $a = 12.34e1__2; printf("%.0f\n", $a);  # 42
464 no warnings 'syntax' ;
465 $a = _123; print "$a\n";
466 $a = 1_23; print "$a\n";
467 $a = 12_3; print "$a\n";
468 $a = 123_; print "$a\n";
469 $a = _+123; print "$a\n";
470 $a = +_123; print "$a\n";
471 $a = +1_23; print "$a\n";
472 $a = +12_3; print "$a\n";
473 $a = +123_; print "$a\n";
474 $a = _-123; print "$a\n";
475 $a = -_123; print "$a\n";
476 $a = -1_23; print "$a\n";
477 $a = -12_3; print "$a\n";
478 $a = -123_; print "$a\n";
479 $a = 123._456; print "$a\n";
480 $a = 123.4_56; print "$a\n";
481 $a = 123.45_6; print "$a\n";
482 $a = 123.456_; print "$a\n";
483 $a = +123._456; print "$a\n";
484 $a = +123.4_56; print "$a\n";
485 $a = +123.45_6; print "$a\n";
486 $a = +123.456_; print "$a\n";
487 $a = -123._456; print "$a\n";
488 $a = -123.4_56; print "$a\n";
489 $a = -123.45_6; print "$a\n";
490 $a = -123.456_; print "$a\n";
491 $a = 123.456E_12; printf("%.0f\n", $a);
492 $a = 123.456E1_2; printf("%.0f\n", $a);
493 $a = 123.456E12_; printf("%.0f\n", $a);
494 $a = 123.456E_+12; printf("%.0f\n", $a);
495 $a = 123.456E+_12; printf("%.0f\n", $a);
496 $a = 123.456E+1_2; printf("%.0f\n", $a);
497 $a = 123.456E+12_; printf("%.0f\n", $a);
498 $a = 123.456E_-12; print "$a\n";
499 $a = 123.456E-_12; print "$a\n";
500 $a = 123.456E-1_2; print "$a\n";
501 $a = 123.456E-12_; print "$a\n";
502 $a = 1__23; print "$a\n";
503 $a = 12.3__4; print "$a\n";
504 $a = 12.34e1__2; printf("%.0f\n", $a);
505 EXPECT
506 OPTIONS regex
507 Misplaced _ in number at - line 6.
508 Misplaced _ in number at - line 11.
509 Misplaced _ in number at - line 16.
510 Misplaced _ in number at - line 17.
511 Misplaced _ in number at - line 20.
512 Misplaced _ in number at - line 21.
513 Misplaced _ in number at - line 24.
514 Misplaced _ in number at - line 25.
515 Misplaced _ in number at - line 28.
516 Misplaced _ in number at - line 29.
517 Misplaced _ in number at - line 31.
518 Misplaced _ in number at - line 32.
519 Misplaced _ in number at - line 33.
520 Misplaced _ in number at - line 35.
521 Misplaced _ in number at - line 36.
522 Misplaced _ in number at - line 37.
523 Misplaced _ in number at - line 39.
524 Misplaced _ in number at - line 40.
525 Misplaced _ in number at - line 41.
526 Misplaced _ in number at - line 42.
527 _123
528 123
529 123
530 123
531 123
532 _123
533 123
534 123
535 123
536 -123
537 -_123
538 -123
539 -123
540 -123
541 123.456
542 123.456
543 123.456
544 123.456
545 123.456
546 123.456
547 123.456
548 123.456
549 -123.456
550 -123.456
551 -123.456
552 -123.456
553 123456000000000
554 123456000000000
555 123456000000000
556 123456000000000
557 123456000000000
558 123456000000000
559 123456000000000
560 1.23456e-0?10
561 1.23456e-0?10
562 1.23456e-0?10
563 1.23456e-0?10
564 123
565 12.34
566 12340000000000
567 _123
568 123
569 123
570 123
571 123
572 _123
573 123
574 123
575 123
576 -123
577 -_123
578 -123
579 -123
580 -123
581 123.456
582 123.456
583 123.456
584 123.456
585 123.456
586 123.456
587 123.456
588 123.456
589 -123.456
590 -123.456
591 -123.456
592 -123.456
593 123456000000000
594 123456000000000
595 123456000000000
596 123456000000000
597 123456000000000
598 123456000000000
599 123456000000000
600 1.23456e-0?10
601 1.23456e-0?10
602 1.23456e-0?10
603 1.23456e-0?10
604 123
605 12.34
606 12340000000000
607 ########
608 # toke.c
609 use warnings 'bareword' ;
610 #line 25 "bar"
611 $a = FRED:: ;
612 no warnings 'bareword' ;
613 #line 25 "bar"
614 $a = FRED:: ;
615 EXPECT
616 Bareword "FRED::" refers to nonexistent package at bar line 25.
617 ########
618 # toke.c
619 use warnings 'ambiguous' ;
620 sub time {}
621 my $a = time() ;
622 no warnings 'ambiguous' ;
623 my $b = time() ;
624 EXPECT
625 Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
626 ########
627 # toke.c
628 use warnings ;
629 eval <<'EOE';
630 #  line 30 "foo"
631 warn "yelp";
632 {
633   $_ = " \x{123} " ;
634 }
635 EOE
636 EXPECT
637 yelp at foo line 30.
638 ########
639 # toke.c
640 my $a = rand + 4 ;
641 EXPECT
642 Warning: Use of "rand" without parentheses is ambiguous at - line 2.
643 ########
644 # toke.c
645 $^W = 0 ;
646 my $a = rand + 4 ;
647 {
648     no warnings 'ambiguous' ;
649     $a = rand + 4 ;
650     use warnings 'ambiguous' ;
651     $a = rand + 4 ;
652 }
653 $a = rand + 4 ;
654 EXPECT
655 Warning: Use of "rand" without parentheses is ambiguous at - line 3.
656 Warning: Use of "rand" without parentheses is ambiguous at - line 8.
657 Warning: Use of "rand" without parentheses is ambiguous at - line 10.
658 ########
659 # [perl #97110]
660 sub myrand(;$) { }
661 sub whatever($) { }
662 my $a = myrand + 4 ;
663 my $b = whatever + 4 ;
664 EXPECT
665 Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
666 ########
667 # toke.c
668 use warnings "ambiguous";
669 print for keys %+; # should not warn
670 EXPECT
671 ########
672 # toke.c
673 sub fred {};
674 -fred ;
675 EXPECT
676 Ambiguous use of -fred resolved as -&fred() at - line 3.
677 ########
678 # toke.c
679 $^W = 0 ;
680 sub fred {} ;
681 -fred ;
682 {
683     no warnings 'ambiguous' ;
684     -fred ;
685     use warnings 'ambiguous' ;
686     -fred ;
687 }
688 -fred ;
689 EXPECT
690 Ambiguous use of -fred resolved as -&fred() at - line 4.
691 Ambiguous use of -fred resolved as -&fred() at - line 9.
692 Ambiguous use of -fred resolved as -&fred() at - line 11.
693 ########
694 # toke.c
695 open FOO || time;
696 open local *FOO; # should be ok
697 EXPECT
698 Precedence problem: open FOO should be open(FOO) at - line 2.
699 ########
700 # toke.c (and [perl #16184])
701 open FOO => "<&0"; close FOO;
702 EXPECT
703 ########
704 # toke.c
705 $^W = 0 ;
706 open FOO || time;
707 {
708     no warnings 'precedence' ;
709     open FOO || time;
710     use warnings 'precedence' ;
711     open FOO || time;
712 }
713 open FOO || time;
714 open Foo::BAR; # this should not warn
715 EXPECT
716 Precedence problem: open FOO should be open(FOO) at - line 3.
717 Precedence problem: open FOO should be open(FOO) at - line 8.
718 Precedence problem: open FOO should be open(FOO) at - line 10.
719 ########
720 # toke.c
721 $^W = 0 ;
722 *foo *foo ;
723 {
724     no warnings 'ambiguous' ;
725     *foo *foo ;
726     use warnings 'ambiguous' ;
727     *foo *foo ;
728 }
729 *foo *foo ;
730 EXPECT
731 Operator or semicolon missing before *foo at - line 3.
732 Ambiguous use of * resolved as operator * at - line 3.
733 Operator or semicolon missing before *foo at - line 8.
734 Ambiguous use of * resolved as operator * at - line 8.
735 Operator or semicolon missing before *foo at - line 10.
736 Ambiguous use of * resolved as operator * at - line 10.
737 ########
738 # toke.c
739 use utf8;
740 use open qw( :utf8 :std );
741 $^W = 0 ;
742 *foo *foo ;
743 {
744     no warnings 'ambiguous' ;
745     *foo *foo ;
746     use warnings 'ambiguous' ;
747     *foo *foo ;
748 }
749 *foo *foo ;
750 EXPECT
751 Operator or semicolon missing before *foo at - line 5.
752 Ambiguous use of * resolved as operator * at - line 5.
753 Operator or semicolon missing before *foo at - line 10.
754 Ambiguous use of * resolved as operator * at - line 10.
755 Operator or semicolon missing before *foo at - line 12.
756 Ambiguous use of * resolved as operator * at - line 12.
757 ########
758 # toke.c
759 use warnings 'misc' ;
760 my $a = "\m" ;
761 no warnings 'misc' ;
762 $a = "\m" ;
763 EXPECT
764 Unrecognized escape \m passed through at - line 3.
765 ########
766 # toke.c
767 use warnings 'misc' ;
768 my $a = "abcd\E" ;
769 no warnings 'misc' ;
770 $a = "abcd\E" ;
771 EXPECT
772 Useless use of \E at - line 3.
773 ########
774 # toke.c
775 use warnings 'portable' ;
776 my $a =  0b011111111111111111111111111111110 ;
777    $a =  0b011111111111111111111111111111111 ;
778    $a =  0b111111111111111111111111111111111 ;
779    $a =  0x0fffffffe ;
780    $a =  0x0ffffffff ;
781    $a =  0x1ffffffff ;
782    $a =  0037777777776 ;
783    $a =  0037777777777 ;
784    $a =  0047777777777 ;
785 no warnings 'portable' ;
786    $a =  0b011111111111111111111111111111110 ;
787    $a =  0b011111111111111111111111111111111 ;
788    $a =  0b111111111111111111111111111111111 ;
789    $a =  0x0fffffffe ;
790    $a =  0x0ffffffff ;
791    $a =  0x1ffffffff ;
792    $a =  0037777777776 ;
793    $a =  0037777777777 ;
794    $a =  0047777777777 ;
795 EXPECT
796 Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
797 Hexadecimal number > 0xffffffff non-portable at - line 8.
798 Octal number > 037777777777 non-portable at - line 11.
799 ########
800 # toke.c
801 use warnings 'overflow' ;
802 my $a =  0b011111111111111111111111111111110 ;
803    $a =  0b011111111111111111111111111111111 ;
804    $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
805    $a =  0x0fffffffe ;
806    $a =  0x0ffffffff ;
807    $a =  0x10000000000000000 ;
808    $a =  0037777777776 ;
809    $a =  0037777777777 ;
810    $a =  002000000000000000000000;
811 no warnings 'overflow' ;
812    $a =  0b011111111111111111111111111111110 ;
813    $a =  0b011111111111111111111111111111111 ;
814    $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
815    $a =  0x0fffffffe ;
816    $a =  0x0ffffffff ;
817    $a =  0x10000000000000000 ;
818    $a =  0037777777776 ;
819    $a =  0037777777777 ;
820    $a =  002000000000000000000000;
821 EXPECT
822 Integer overflow in binary number at - line 5.
823 Integer overflow in hexadecimal number at - line 8.
824 Integer overflow in octal number at - line 11.
825 ########
826 # toke.c
827 BEGIN { $^C = 1; }
828 use warnings 'misc';
829 dump;
830 CORE::dump;
831 EXPECT
832 dump() better written as CORE::dump() at - line 4.
833 - syntax OK
834 ########
835 # toke.c
836 use warnings 'misc';
837 use subs qw/dump/;
838 sub dump { print "no warning for overridden dump\n"; }
839 dump;
840 EXPECT
841 no warning for overridden dump
842 ########
843 # toke.c
844 use warnings 'ambiguous';
845 "@mjd_previously_unused_array";        
846 no warnings 'ambiguous';
847 "@mjd_previously_unused_array2";        
848 EXPECT
849 Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
850 ########
851 # toke.c
852 use utf8;
853 use open qw( :utf8 :std );
854 use warnings 'ambiguous';
855 "@mjd_previously_unused_àrray";        
856 no warnings 'ambiguous';
857 "@mjd_previously_unused_àrray2";        
858 EXPECT
859 Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5.
860 ########
861 # toke.c
862 use utf8;
863 use open qw( :utf8 :std );
864 use warnings 'ambiguous';
865 "@mjd_previously_unused_ぁrrぁy";        
866 no warnings 'ambiguous';
867 "@mjd_previously_unused_ぁrrぁy2";        
868 EXPECT
869 Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5.
870 ########
871 # toke.c
872 # 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
873 use warnings 'regexp';
874 "foo" =~ /foo/c;
875 "foo" =~ /foo/cg;
876 no warnings 'regexp';
877 "foo" =~ /foo/c;
878 "foo" =~ /foo/cg;
879 EXPECT
880 Use of /c modifier is meaningless without /g at - line 4.
881 ########
882 # toke.c
883 # 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
884 use warnings 'regexp';
885 $_ = "ab" ; 
886 s/ab/ab/c;
887 s/ab/ab/cg;
888 no warnings 'regexp';
889 s/ab/ab/c;
890 s/ab/ab/cg;
891 EXPECT
892 Use of /c modifier is meaningless in s/// at - line 5.
893 Use of /c modifier is meaningless in s/// at - line 6.
894 ########
895 -wa
896 # toke.c
897 # 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
898 print "@F\n";
899 EXPECT
900
901 ########
902 -w
903 # toke.c
904 # 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
905 print "@F\n";
906 EXPECT
907 Possible unintended interpolation of @F in string at - line 4.
908 Name "main::F" used only once: possible typo at - line 4.
909 ########
910 -wa
911 # toke.c
912 # 20020414 mjd-perl-patch+@plover.com
913 EXPECT
914
915 ########
916 # toke.c
917 # 20020414 mjd-perl-patch+@plover.com
918 # In 5.7.3, this emitted "Possible unintended interpolation" warnings
919 use warnings 'ambiguous';
920 $s = "(@-)(@+)";
921 EXPECT
922
923 ########
924 # toke.c
925 # mandatory warning
926 eval q/if ($a) { } elseif ($b) { }/;
927 no warnings "syntax";
928 eval q/if ($a) { } elseif ($b) { }/;
929 EXPECT
930 elseif should be elsif at (eval 1) line 1.
931 ########
932 # toke.c
933 # mandatory warning
934 eval q/5 6/;
935 no warnings "syntax";
936 eval q/5 6/;
937 EXPECT
938 Number found where operator expected at (eval 1) line 1, near "5 6"
939         (Missing operator before  6?)
940 ########
941 # toke.c
942 use warnings "syntax";
943 $_ = $a = 1;
944 $a !=~  /1/;
945 $a !=~ m#1#;
946 $a !=~/1/;
947 $a !=~ ?/?;
948 $a !=~ y/1//;
949 $a !=~ tr/1//;
950 $a !=~ s/1//;
951 $a != ~/1/;
952 no warnings "syntax";
953 $a !=~  /1/;
954 $a !=~ m#1#;
955 $a !=~/1/;
956 $a !=~ ?/?;
957 $a !=~ y/1//;
958 $a !=~ tr/1//;
959 $a !=~ s/1//;
960 EXPECT
961 !=~ should be !~ at - line 4.
962 !=~ should be !~ at - line 5.
963 !=~ should be !~ at - line 6.
964 !=~ should be !~ at - line 7.
965 !=~ should be !~ at - line 8.
966 !=~ should be !~ at - line 9.
967 !=~ should be !~ at - line 10.
968 ########
969 # toke.c
970 our $foo :unique;
971 sub pam :locked;
972 sub glipp :locked {
973 }
974 sub whack_eth ($) : locked {
975 }
976 no warnings 'deprecated';
977 our $bar :unique;
978 sub zapeth :locked;
979 sub ker_plop :locked {
980 }
981 sub swa_a_p ($) : locked {
982 }
983 EXPECT
984 Use of :unique is deprecated at - line 2.
985 Use of :locked is deprecated at - line 3.
986 Use of :locked is deprecated at - line 4.
987 Use of :locked is deprecated at - line 6.
988 ########
989 # toke.c
990 use warnings "syntax";
991 sub proto_after_array(@$);
992 sub proto_after_arref(\@$);
993 sub proto_after_arref2(\[@$]);
994 sub proto_after_arref3(\[@$]_);
995 sub proto_after_hash(%$);
996 sub proto_after_hashref(\%$);
997 sub proto_after_hashref2(\[%$]);
998 sub underscore_last_pos($_);
999 sub underscore2($_;$);
1000 sub underscore_fail($_$);
1001 sub underscore_after_at(@_);
1002 no warnings "syntax";
1003 sub proto_after_array(@$);
1004 sub proto_after_hash(%$);
1005 sub underscore_fail($_$);
1006 EXPECT
1007 Prototype after '@' for main::proto_after_array : @$ at - line 3.
1008 Prototype after '%' for main::proto_after_hash : %$ at - line 7.
1009 Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
1010 Prototype after '@' for main::underscore_after_at : @_ at - line 13.
1011 ########
1012 # toke.c
1013 use warnings "ambiguous";
1014 "foo\nn" =~ /^foo$\n/;
1015 "foo\nn" =~ /^foo${\}n/;
1016 my $foo = qr/^foo$\n/;
1017 my $bar = qr/^foo${\}n/;
1018 no warnings "ambiguous";
1019 "foo\nn" =~ /^foo$\n/;
1020 "foo\nn" =~ /^foo${\}n/;
1021 my $foo = qr/^foo$\n/;
1022 my $bar = qr/^foo${\}n/;
1023 EXPECT
1024 Possible unintended interpolation of $\ in regex at - line 3.
1025 Possible unintended interpolation of $\ in regex at - line 5.
1026 ########
1027 # toke.c
1028 use warnings 'syntax' ;
1029 my $a = "\o";
1030 my $a = "\o{";
1031 my $a = "\o{}";
1032 no warnings 'syntax' ;
1033 my $a = "\o";
1034 my $a = "\o{";
1035 my $a = "\o{}";
1036 EXPECT
1037 Missing braces on \o{} at - line 3, within string
1038 Missing right brace on \o{ at - line 4, within string
1039 Number with no digits at - line 5, within string
1040 BEGIN not safe after errors--compilation aborted at - line 6.
1041 ########
1042 # toke.c
1043 use warnings 'digit' ;
1044 my $a = "\o{1238456}";
1045 no warnings 'digit' ;
1046 my $a = "\o{1238456}";
1047 EXPECT
1048 Non-octal character '8'.  Resolved as "\o{123}" at - line 3.
1049 ########
1050 # toke.c
1051 use warnings;
1052 my $a = "foo";
1053 print $a =~ ?f? ? "yes\n" : "no\n" foreach 0..2;
1054 EXPECT
1055 Use of ?PATTERN? without explicit operator is deprecated at - line 4.
1056 yes
1057 no
1058 no
1059 ########
1060 # toke.c
1061 use warnings;
1062 my $a = "\c{ack}";
1063 $a = "\c,";
1064 $a = "\c`";
1065 no warnings 'syntax';
1066 $a = "\c{ack}";
1067 $a = "\c,";
1068 $a = "\c`";
1069 no warnings 'deprecated';
1070 EXPECT
1071 "\c{" is deprecated and is more clearly written as ";" at - line 3.
1072 "\c," is more clearly written simply as "l" at - line 4.
1073 "\c`" is more clearly written simply as "\ " at - line 5.
1074 "\c{" is deprecated and is more clearly written as ";" at - line 7.
1075 ########
1076 # toke.c
1077 use warnings 'syntax' ;
1078 my $a = qr/foo/du;
1079 $a = qr/foo/lai;
1080 $a = qr/foo/lil;
1081 $a = qr/foo/aia;
1082 $a = qr/foo/aaia;
1083 no warnings 'syntax' ;
1084 my $a = qr/foo/du;
1085 EXPECT
1086 Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
1087 Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
1088 Regexp modifier "/l" may not appear twice at - line 5, near "= "
1089 Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
1090 BEGIN not safe after errors--compilation aborted at - line 8.
1091 ########
1092 # toke.c
1093 # [perl #4362]
1094 eval "print q\xabfoo";
1095 print "ok\n" if
1096     $@ =~ /Can't find string terminator "\xab" anywhere before EOF/;
1097 EXPECT
1098 ok