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