This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
5a4af815d350e4088301679d778687c83da87a61
[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 warnings 'misc' ;
740 my $a = "\m" ;
741 no warnings 'misc' ;
742 $a = "\m" ;
743 EXPECT
744 Unrecognized escape \m passed through at - line 3.
745 ########
746 # toke.c
747 use warnings 'misc' ;
748 my $a = "abcd\E" ;
749 no warnings 'misc' ;
750 $a = "abcd\E" ;
751 EXPECT
752 Useless use of \E at - line 3.
753 ########
754 # toke.c
755 use warnings 'portable' ;
756 my $a =  0b011111111111111111111111111111110 ;
757    $a =  0b011111111111111111111111111111111 ;
758    $a =  0b111111111111111111111111111111111 ;
759    $a =  0x0fffffffe ;
760    $a =  0x0ffffffff ;
761    $a =  0x1ffffffff ;
762    $a =  0037777777776 ;
763    $a =  0037777777777 ;
764    $a =  0047777777777 ;
765 no warnings 'portable' ;
766    $a =  0b011111111111111111111111111111110 ;
767    $a =  0b011111111111111111111111111111111 ;
768    $a =  0b111111111111111111111111111111111 ;
769    $a =  0x0fffffffe ;
770    $a =  0x0ffffffff ;
771    $a =  0x1ffffffff ;
772    $a =  0037777777776 ;
773    $a =  0037777777777 ;
774    $a =  0047777777777 ;
775 EXPECT
776 Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
777 Hexadecimal number > 0xffffffff non-portable at - line 8.
778 Octal number > 037777777777 non-portable at - line 11.
779 ########
780 # toke.c
781 use warnings 'overflow' ;
782 my $a =  0b011111111111111111111111111111110 ;
783    $a =  0b011111111111111111111111111111111 ;
784    $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
785    $a =  0x0fffffffe ;
786    $a =  0x0ffffffff ;
787    $a =  0x10000000000000000 ;
788    $a =  0037777777776 ;
789    $a =  0037777777777 ;
790    $a =  002000000000000000000000;
791 no warnings 'overflow' ;
792    $a =  0b011111111111111111111111111111110 ;
793    $a =  0b011111111111111111111111111111111 ;
794    $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
795    $a =  0x0fffffffe ;
796    $a =  0x0ffffffff ;
797    $a =  0x10000000000000000 ;
798    $a =  0037777777776 ;
799    $a =  0037777777777 ;
800    $a =  002000000000000000000000;
801 EXPECT
802 Integer overflow in binary number at - line 5.
803 Integer overflow in hexadecimal number at - line 8.
804 Integer overflow in octal number at - line 11.
805 ########
806 # toke.c
807 BEGIN { $^C = 1; }
808 use warnings 'misc';
809 dump;
810 CORE::dump;
811 EXPECT
812 dump() better written as CORE::dump() at - line 4.
813 - syntax OK
814 ########
815 # toke.c
816 use warnings 'misc';
817 use subs qw/dump/;
818 sub dump { print "no warning for overridden dump\n"; }
819 dump;
820 EXPECT
821 no warning for overridden dump
822 ########
823 # toke.c
824 use warnings 'ambiguous';
825 "@mjd_previously_unused_array";        
826 no warnings 'ambiguous';
827 "@mjd_previously_unused_array";        
828 EXPECT
829 Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
830 ########
831 # toke.c
832 # 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
833 use warnings 'regexp';
834 "foo" =~ /foo/c;
835 "foo" =~ /foo/cg;
836 no warnings 'regexp';
837 "foo" =~ /foo/c;
838 "foo" =~ /foo/cg;
839 EXPECT
840 Use of /c modifier is meaningless without /g at - line 4.
841 ########
842 # toke.c
843 # 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
844 use warnings 'regexp';
845 $_ = "ab" ; 
846 s/ab/ab/c;
847 s/ab/ab/cg;
848 no warnings 'regexp';
849 s/ab/ab/c;
850 s/ab/ab/cg;
851 EXPECT
852 Use of /c modifier is meaningless in s/// at - line 5.
853 Use of /c modifier is meaningless in s/// at - line 6.
854 ########
855 -wa
856 # toke.c
857 # 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
858 print "@F\n";
859 EXPECT
860
861 ########
862 -w
863 # toke.c
864 # 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
865 print "@F\n";
866 EXPECT
867 Possible unintended interpolation of @F in string at - line 4.
868 Name "main::F" used only once: possible typo at - line 4.
869 ########
870 -wa
871 # toke.c
872 # 20020414 mjd-perl-patch+@plover.com
873 EXPECT
874
875 ########
876 # toke.c
877 # 20020414 mjd-perl-patch+@plover.com
878 # In 5.7.3, this emitted "Possible unintended interpolation" warnings
879 use warnings 'ambiguous';
880 $s = "(@-)(@+)";
881 EXPECT
882
883 ########
884 # toke.c
885 # mandatory warning
886 eval q/if ($a) { } elseif ($b) { }/;
887 no warnings "syntax";
888 eval q/if ($a) { } elseif ($b) { }/;
889 EXPECT
890 elseif should be elsif at (eval 1) line 1.
891 ########
892 # toke.c
893 # mandatory warning
894 eval q/5 6/;
895 no warnings "syntax";
896 eval q/5 6/;
897 EXPECT
898 Number found where operator expected at (eval 1) line 1, near "5 6"
899         (Missing operator before  6?)
900 ########
901 # toke.c
902 use warnings "syntax";
903 $_ = $a = 1;
904 $a !=~  /1/;
905 $a !=~ m#1#;
906 $a !=~/1/;
907 $a !=~ ?/?;
908 $a !=~ y/1//;
909 $a !=~ tr/1//;
910 $a !=~ s/1//;
911 $a != ~/1/;
912 no warnings "syntax";
913 $a !=~  /1/;
914 $a !=~ m#1#;
915 $a !=~/1/;
916 $a !=~ ?/?;
917 $a !=~ y/1//;
918 $a !=~ tr/1//;
919 $a !=~ s/1//;
920 EXPECT
921 !=~ should be !~ at - line 4.
922 !=~ should be !~ at - line 5.
923 !=~ should be !~ at - line 6.
924 !=~ should be !~ at - line 7.
925 !=~ should be !~ at - line 8.
926 !=~ should be !~ at - line 9.
927 !=~ should be !~ at - line 10.
928 ########
929 # toke.c
930 our $foo :unique;
931 sub pam :locked;
932 sub glipp :locked {
933 }
934 sub whack_eth ($) : locked {
935 }
936 no warnings 'deprecated';
937 our $bar :unique;
938 sub zapeth :locked;
939 sub ker_plop :locked {
940 }
941 sub swa_a_p ($) : locked {
942 }
943 EXPECT
944 Use of :unique is deprecated at - line 2.
945 Use of :locked is deprecated at - line 3.
946 Use of :locked is deprecated at - line 4.
947 Use of :locked is deprecated at - line 6.
948 ########
949 # toke.c
950 use warnings "syntax";
951 sub proto_after_array(@$);
952 sub proto_after_arref(\@$);
953 sub proto_after_arref2(\[@$]);
954 sub proto_after_arref3(\[@$]_);
955 sub proto_after_hash(%$);
956 sub proto_after_hashref(\%$);
957 sub proto_after_hashref2(\[%$]);
958 sub underscore_last_pos($_);
959 sub underscore2($_;$);
960 sub underscore_fail($_$);
961 sub underscore_after_at(@_);
962 no warnings "syntax";
963 sub proto_after_array(@$);
964 sub proto_after_hash(%$);
965 sub underscore_fail($_$);
966 EXPECT
967 Prototype after '@' for main::proto_after_array : @$ at - line 3.
968 Prototype after '%' for main::proto_after_hash : %$ at - line 7.
969 Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
970 Prototype after '@' for main::underscore_after_at : @_ at - line 13.
971 ########
972 # toke.c
973 use warnings "ambiguous";
974 "foo\nn" =~ /^foo$\n/;
975 "foo\nn" =~ /^foo${\}n/;
976 my $foo = qr/^foo$\n/;
977 my $bar = qr/^foo${\}n/;
978 no warnings "ambiguous";
979 "foo\nn" =~ /^foo$\n/;
980 "foo\nn" =~ /^foo${\}n/;
981 my $foo = qr/^foo$\n/;
982 my $bar = qr/^foo${\}n/;
983 EXPECT
984 Possible unintended interpolation of $\ in regex at - line 3.
985 Possible unintended interpolation of $\ in regex at - line 5.
986 ########
987 # toke.c
988 use warnings 'syntax' ;
989 my $a = "\o";
990 my $a = "\o{";
991 my $a = "\o{}";
992 no warnings 'syntax' ;
993 my $a = "\o";
994 my $a = "\o{";
995 my $a = "\o{}";
996 EXPECT
997 Missing braces on \o{} at - line 3, within string
998 Missing right brace on \o{ at - line 4, within string
999 Number with no digits at - line 5, within string
1000 BEGIN not safe after errors--compilation aborted at - line 6.
1001 ########
1002 # toke.c
1003 use warnings 'digit' ;
1004 my $a = "\o{1238456}";
1005 no warnings 'digit' ;
1006 my $a = "\o{1238456}";
1007 EXPECT
1008 Non-octal character '8'.  Resolved as "\o{123}" at - line 3.
1009 ########
1010 # toke.c
1011 use warnings;
1012 my $a = "foo";
1013 print $a =~ ?f? ? "yes\n" : "no\n" foreach 0..2;
1014 EXPECT
1015 Use of ?PATTERN? without explicit operator is deprecated at - line 4.
1016 yes
1017 no
1018 no
1019 ########
1020 # toke.c
1021 use warnings;
1022 my $a = "\c{ack}";
1023 $a = "\c,";
1024 $a = "\c`";
1025 no warnings 'syntax';
1026 $a = "\c{ack}";
1027 $a = "\c,";
1028 $a = "\c`";
1029 no warnings 'deprecated';
1030 EXPECT
1031 "\c{" is deprecated and is more clearly written as ";" at - line 3.
1032 "\c," is more clearly written simply as "l" at - line 4.
1033 "\c`" is more clearly written simply as "\ " at - line 5.
1034 "\c{" is deprecated and is more clearly written as ";" at - line 7.
1035 ########
1036 # toke.c
1037 use warnings 'syntax' ;
1038 my $a = qr/foo/du;
1039 $a = qr/foo/lai;
1040 $a = qr/foo/lil;
1041 $a = qr/foo/aia;
1042 $a = qr/foo/aaia;
1043 no warnings 'syntax' ;
1044 my $a = qr/foo/du;
1045 EXPECT
1046 Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
1047 Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
1048 Regexp modifier "/l" may not appear twice at - line 5, near "= "
1049 Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
1050 BEGIN not safe after errors--compilation aborted at - line 8.
1051 ########
1052 # toke.c
1053 # [perl #4362]
1054 eval "print q\xabfoo";
1055 print "ok\n" if
1056     $@ =~ /Can't find string terminator "\xab" anywhere before EOF/;
1057 EXPECT
1058 ok