This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ExtUtils::Packlist: Restore 5.005 compatibility
[perl5.git] / t / lib / warnings / toke
CommitLineData
599cee73
PM
1toke.c AOK
2
3 we seem to have lost a few ambiguous warnings!!
4
5
599cee73
PM
6 $a = <<;
7 Use of comma-less variable list is deprecated
8 (called 3 times via depcom)
9
10 \1 better written as $1
4438c4b7 11 use warnings 'syntax' ;
599cee73
PM
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
599cee73
PM
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
599cee73
PM
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
767a6a26
PM
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 ;
ac206dc8
RGS
104
105 dump() better written as CORE::dump()
4ac733c9
MJD
106
107 Use of /c modifier is meaningless without /g
108
64e578a2
MJD
109 Use of /c modifier is meaningless in s///
110
0453d815
PM
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
599cee73
PM
126__END__
127# toke.c
599cee73
PM
128format STDOUT =
129@<<< @||| @>>> @>>>
130$a $b "abc" 'def'
131.
4438c4b7 132no warnings 'deprecated' ;
0453d815
PM
133format STDOUT =
134@<<< @||| @>>> @>>>
135$a $b "abc" 'def'
136.
599cee73 137EXPECT
d1d15184
NC
138Use of comma-less variable list is deprecated at - line 4.
139Use of comma-less variable list is deprecated at - line 4.
140Use of comma-less variable list is deprecated at - line 4.
599cee73
PM
141########
142# toke.c
e6897b1a 143$a =~ m/$foo/sand $bar;
aa78b661 144$a =~ s/$foo/fool/sand $bar;
599cee73
PM
145$a = <<;
146
4438c4b7 147no warnings 'deprecated' ;
e6897b1a 148$a =~ m/$foo/sand $bar;
aa78b661 149$a =~ s/$foo/fool/sand $bar;
0453d815
PM
150$a = <<;
151
599cee73 152EXPECT
e6897b1a 153Having no space between pattern and following word is deprecated at - line 2.
aa78b661
KW
154Having no space between pattern and following word is deprecated at - line 3.
155Use of bare << to mean <<"" is deprecated at - line 4.
599cee73
PM
156########
157# toke.c
4438c4b7 158use warnings 'syntax' ;
599cee73 159s/(abc)/\1/;
4438c4b7 160no warnings 'syntax' ;
0453d815 161s/(abc)/\1/;
599cee73
PM
162EXPECT
163\1 better written as $1 at - line 3.
164########
165# toke.c
4438c4b7 166use warnings 'semicolon' ;
599cee73
PM
167$a = 1
168&time ;
4438c4b7 169no warnings 'semicolon' ;
0453d815
PM
170$a = 1
171&time ;
599cee73
PM
172EXPECT
173Semicolon seems to be missing at - line 3.
174########
175# toke.c
4438c4b7 176use warnings 'syntax' ;
599cee73
PM
177my $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 ;
187EXPECT
7f01dc7a
JH
188Reversed += operator at - line 3.
189Reversed -= operator at - line 4.
190Reversed *= operator at - line 5.
191Reversed %= operator at - line 6.
192Reversed &= operator at - line 7.
193Reversed .= operator at - line 8.
194Reversed ^= operator at - line 9.
195Reversed |= operator at - line 10.
196Reversed <= operator at - line 11.
197syntax error at - line 8, near "=."
198syntax error at - line 9, near "=^"
199syntax error at - line 10, near "=|"
200Unterminated <> operator at - line 11.
599cee73
PM
201########
202# toke.c
4438c4b7 203no warnings 'syntax' ;
0453d815
PM
204my $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 ;
214EXPECT
7f01dc7a
JH
215syntax error at - line 8, near "=."
216syntax error at - line 9, near "=^"
217syntax error at - line 10, near "=|"
218Unterminated <> operator at - line 11.
0453d815
PM
219########
220# toke.c
4438c4b7 221use warnings 'syntax' ;
599cee73 222my $a = $a[1,2] ;
4438c4b7 223no warnings 'syntax' ;
0453d815 224my $a = $a[1,2] ;
599cee73
PM
225EXPECT
226Multidimensional syntax $a[1,2] not supported at - line 3.
227########
228# toke.c
4438c4b7 229use warnings 'syntax' ;
599cee73 230sub fred {} ; $SIG{TERM} = fred;
4438c4b7 231no warnings 'syntax' ;
0453d815 232$SIG{TERM} = fred;
599cee73
PM
233EXPECT
234You need to quote "fred" at - line 3.
235########
236# toke.c
4438c4b7 237use warnings 'syntax' ;
599cee73
PM
238@a[3] = 2;
239@a{3} = 2;
4438c4b7 240no warnings 'syntax' ;
0453d815
PM
241@a[3] = 2;
242@a{3} = 2;
599cee73
PM
243EXPECT
244Scalar value @a[3] better written as $a[3] at - line 3.
245Scalar value @a{3} better written as $a{3} at - line 4.
246########
247# toke.c
4438c4b7 248use warnings 'syntax' ;
599cee73
PM
249$_ = "ab" ;
250s/(ab)/\1/e;
4438c4b7 251no warnings 'syntax' ;
0453d815
PM
252$_ = "ab" ;
253s/(ab)/\1/e;
599cee73
PM
254EXPECT
255Can't use \1 to mean $1 in expression at - line 4.
256########
257# toke.c
4438c4b7 258use warnings 'reserved' ;
599cee73 259$a = abc;
1c3923b3
GS
260$a = { def
261
262=> 1 };
4438c4b7 263no warnings 'reserved' ;
0453d815 264$a = abc;
599cee73
PM
265EXPECT
266Unquoted string "abc" may clash with future reserved word at - line 3.
267########
268# toke.c
e476b1b5 269use warnings 'qw' ;
599cee73 270@a = qw(a, b, c) ;
e476b1b5 271no warnings 'qw' ;
0453d815 272@a = qw(a, b, c) ;
599cee73
PM
273EXPECT
274Possible attempt to separate words with commas at - line 3.
275########
276# toke.c
e476b1b5 277use warnings 'qw' ;
7e03b518 278@a = qw(a b c # #) ;
e476b1b5 279no warnings 'qw' ;
7e03b518 280@a = qw(a b c # #) ;
599cee73
PM
281EXPECT
282Possible attempt to put comments in qw() list at - line 3.
283########
284# toke.c
7e03b518
EB
285use warnings 'qw' ;
286@a = qw(a, b, c # #) ;
287no warnings 'qw' ;
288@a = qw(a, b, c # #) ;
289EXPECT
290Possible attempt to separate words with commas at - line 3.
291Possible attempt to put comments in qw() list at - line 3.
292########
293# toke.c
4438c4b7 294use warnings 'syntax' ;
b1439985
RGS
295print ("");
296print ("") and $x = 1;
297print ("") or die;
298print ("") // die;
299print (1+2) * 3 if 0; # only this one should warn
300print (1+2) if 0;
599cee73 301EXPECT
b1439985 302print (...) interpreted as function at - line 7.
599cee73
PM
303########
304# toke.c
4438c4b7 305no warnings 'syntax' ;
0453d815
PM
306print ("")
307EXPECT
308
309########
310# toke.c
4438c4b7 311use warnings 'syntax' ;
b1439985
RGS
312printf ("");
313printf ("") . '';
599cee73 314EXPECT
b1439985 315printf (...) interpreted as function at - line 4.
599cee73
PM
316########
317# toke.c
4438c4b7 318no warnings 'syntax' ;
0453d815
PM
319printf ("")
320EXPECT
321
322########
323# toke.c
4438c4b7 324use warnings 'syntax' ;
b1439985
RGS
325sort ("");
326sort ("") . '';
599cee73 327EXPECT
b1439985 328sort (...) interpreted as function at - line 4.
599cee73
PM
329########
330# toke.c
4438c4b7 331no warnings 'syntax' ;
0453d815
PM
332sort ("")
333EXPECT
334
335########
336# toke.c
4438c4b7 337use warnings 'ambiguous' ;
599cee73 338$a = ${time[2]};
4438c4b7 339no warnings 'ambiguous' ;
0453d815 340$a = ${time[2]};
599cee73
PM
341EXPECT
342Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
343########
344# toke.c
4438c4b7 345use warnings 'ambiguous' ;
599cee73
PM
346$a = ${time{2}};
347EXPECT
348Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
349########
350# toke.c
4438c4b7 351no warnings 'ambiguous' ;
0453d815
PM
352$a = ${time{2}};
353EXPECT
354
355########
356# toke.c
4438c4b7 357use warnings 'ambiguous' ;
599cee73 358$a = ${time} ;
4438c4b7 359no warnings 'ambiguous' ;
0453d815 360$a = ${time} ;
599cee73
PM
361EXPECT
362Ambiguous use of ${time} resolved to $time at - line 3.
363########
364# toke.c
4438c4b7 365use warnings 'ambiguous' ;
599cee73
PM
366sub fred {}
367$a = ${fred} ;
4438c4b7 368no warnings 'ambiguous' ;
0453d815 369$a = ${fred} ;
599cee73
PM
370EXPECT
371Ambiguous use of ${fred} resolved to $fred at - line 4.
372########
373# toke.c
4438c4b7 374use warnings 'syntax' ;
7fd134d9
JH
375$a = _123; print "$a\n"; #( 3 string)
376$a = 1_23; print "$a\n";
377$a = 12_3; print "$a\n";
378$a = 123_; print "$a\n"; # 6
379$a = _+123; print "$a\n"; # 7 string)
380$a = +_123; print "$a\n"; #( 8 string)
381$a = +1_23; print "$a\n";
382$a = +12_3; print "$a\n";
383$a = +123_; print "$a\n"; # 11
384$a = _-123; print "$a\n"; #(12 string)
385$a = -_123; print "$a\n"; #(13 string)
386$a = -1_23; print "$a\n";
387$a = -12_3; print "$a\n";
388$a = -123_; print "$a\n"; # 16
389$a = 123._456; print "$a\n"; # 17
390$a = 123.4_56; print "$a\n";
391$a = 123.45_6; print "$a\n";
392$a = 123.456_; print "$a\n"; # 20
393$a = +123._456; print "$a\n"; # 21
394$a = +123.4_56; print "$a\n";
395$a = +123.45_6; print "$a\n";
396$a = +123.456_; print "$a\n"; # 24
397$a = -123._456; print "$a\n"; # 25
398$a = -123.4_56; print "$a\n";
399$a = -123.45_6; print "$a\n";
400$a = -123.456_; print "$a\n"; # 28
2bea9a37
JH
401$a = 123.456E_12; printf("%.0f\n", $a); # 29
402$a = 123.456E1_2; printf("%.0f\n", $a);
403$a = 123.456E12_; printf("%.0f\n", $a); # 31
404$a = 123.456E_+12; printf("%.0f\n", $a); # 32
405$a = 123.456E+_12; printf("%.0f\n", $a); # 33
406$a = 123.456E+1_2; printf("%.0f\n", $a);
407$a = 123.456E+12_; printf("%.0f\n", $a); # 35
7fd134d9
JH
408$a = 123.456E_-12; print "$a\n"; # 36
409$a = 123.456E-_12; print "$a\n"; # 37
410$a = 123.456E-1_2; print "$a\n";
411$a = 123.456E-12_; print "$a\n"; # 39
b3b48e3e
JH
412$a = 1__23; print "$a\n"; # 40
413$a = 12.3__4; print "$a\n"; # 41
2bea9a37 414$a = 12.34e1__2; printf("%.0f\n", $a); # 42
4438c4b7 415no warnings 'syntax' ;
7fd134d9
JH
416$a = _123; print "$a\n";
417$a = 1_23; print "$a\n";
418$a = 12_3; print "$a\n";
419$a = 123_; print "$a\n";
420$a = _+123; print "$a\n";
421$a = +_123; print "$a\n";
422$a = +1_23; print "$a\n";
423$a = +12_3; print "$a\n";
424$a = +123_; print "$a\n";
425$a = _-123; print "$a\n";
426$a = -_123; print "$a\n";
427$a = -1_23; print "$a\n";
428$a = -12_3; print "$a\n";
429$a = -123_; print "$a\n";
430$a = 123._456; print "$a\n";
431$a = 123.4_56; print "$a\n";
432$a = 123.45_6; print "$a\n";
433$a = 123.456_; print "$a\n";
434$a = +123._456; print "$a\n";
435$a = +123.4_56; print "$a\n";
436$a = +123.45_6; print "$a\n";
437$a = +123.456_; print "$a\n";
438$a = -123._456; print "$a\n";
439$a = -123.4_56; print "$a\n";
440$a = -123.45_6; print "$a\n";
441$a = -123.456_; print "$a\n";
2bea9a37
JH
442$a = 123.456E_12; printf("%.0f\n", $a);
443$a = 123.456E1_2; printf("%.0f\n", $a);
444$a = 123.456E12_; printf("%.0f\n", $a);
445$a = 123.456E_+12; printf("%.0f\n", $a);
446$a = 123.456E+_12; printf("%.0f\n", $a);
447$a = 123.456E+1_2; printf("%.0f\n", $a);
448$a = 123.456E+12_; printf("%.0f\n", $a);
7fd134d9
JH
449$a = 123.456E_-12; print "$a\n";
450$a = 123.456E-_12; print "$a\n";
451$a = 123.456E-1_2; print "$a\n";
452$a = 123.456E-12_; print "$a\n";
b3b48e3e
JH
453$a = 1__23; print "$a\n";
454$a = 12.3__4; print "$a\n";
2bea9a37 455$a = 12.34e1__2; printf("%.0f\n", $a);
599cee73 456EXPECT
fbfa96bd 457OPTIONS regex
928753ea 458Misplaced _ in number at - line 6.
928753ea 459Misplaced _ in number at - line 11.
7fd134d9 460Misplaced _ in number at - line 16.
928753ea 461Misplaced _ in number at - line 17.
7fd134d9 462Misplaced _ in number at - line 20.
928753ea 463Misplaced _ in number at - line 21.
7fd134d9
JH
464Misplaced _ in number at - line 24.
465Misplaced _ in number at - line 25.
466Misplaced _ in number at - line 28.
467Misplaced _ in number at - line 29.
468Misplaced _ in number at - line 31.
469Misplaced _ in number at - line 32.
470Misplaced _ in number at - line 33.
471Misplaced _ in number at - line 35.
472Misplaced _ in number at - line 36.
473Misplaced _ in number at - line 37.
474Misplaced _ in number at - line 39.
b3b48e3e
JH
475Misplaced _ in number at - line 40.
476Misplaced _ in number at - line 41.
477Misplaced _ in number at - line 42.
928753ea
JH
478_123
479123
928753ea 480123
7fd134d9
JH
481123
482123
483_123
484123
485123
486123
487-123
488-_123
489-123
490-123
491-123
492123.456
493123.456
494123.456
495123.456
496123.456
497123.456
498123.456
499123.456
500-123.456
501-123.456
502-123.456
503-123.456
504123456000000000
505123456000000000
506123456000000000
507123456000000000
508123456000000000
509123456000000000
510123456000000000
fbfa96bd
NIS
5111.23456e-0?10
5121.23456e-0?10
5131.23456e-0?10
5141.23456e-0?10
b3b48e3e
JH
515123
51612.34
51712340000000000
7fd134d9
JH
518_123
519123
520123
521123
522123
523_123
524123
525123
526123
527-123
528-_123
529-123
530-123
531-123
532123.456
533123.456
534123.456
535123.456
536123.456
928753ea
JH
537123.456
538123.456
928753ea 539123.456
7fd134d9
JH
540-123.456
541-123.456
542-123.456
543-123.456
544123456000000000
545123456000000000
546123456000000000
547123456000000000
548123456000000000
549123456000000000
550123456000000000
fbfa96bd
NIS
5511.23456e-0?10
5521.23456e-0?10
5531.23456e-0?10
5541.23456e-0?10
b3b48e3e
JH
555123
55612.34
55712340000000000
599cee73
PM
558########
559# toke.c
e476b1b5 560use warnings 'bareword' ;
60e6418e 561#line 25 "bar"
599cee73 562$a = FRED:: ;
e476b1b5 563no warnings 'bareword' ;
0453d815
PM
564#line 25 "bar"
565$a = FRED:: ;
599cee73 566EXPECT
60e6418e 567Bareword "FRED::" refers to nonexistent package at bar line 25.
599cee73
PM
568########
569# toke.c
4438c4b7 570use warnings 'ambiguous' ;
599cee73 571sub time {}
0453d815 572my $a = time() ;
4438c4b7 573no warnings 'ambiguous' ;
0453d815 574my $b = time() ;
599cee73
PM
575EXPECT
576Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
577########
578# toke.c
26d16222 579use warnings ;
0453d815 580eval <<'EOE';
df0deb90
GS
581# line 30 "foo"
582warn "yelp";
0453d815 583{
0453d815
PM
584 $_ = " \x{123} " ;
585}
586EOE
587EXPECT
df0deb90 588yelp at foo line 30.
0453d815
PM
589########
590# toke.c
0453d815
PM
591my $a = rand + 4 ;
592EXPECT
2d5ccbba 593Warning: Use of "rand" without parentheses is ambiguous at - line 2.
0453d815
PM
594########
595# toke.c
596$^W = 0 ;
597my $a = rand + 4 ;
598{
4438c4b7 599 no warnings 'ambiguous' ;
0453d815 600 $a = rand + 4 ;
4438c4b7 601 use warnings 'ambiguous' ;
0453d815
PM
602 $a = rand + 4 ;
603}
604$a = rand + 4 ;
605EXPECT
2d5ccbba
IT
606Warning: Use of "rand" without parentheses is ambiguous at - line 3.
607Warning: Use of "rand" without parentheses is ambiguous at - line 8.
608Warning: Use of "rand" without parentheses is ambiguous at - line 10.
0453d815 609########
e19a021b
FC
610# [perl #97110]
611sub myrand(;$) { }
b5fb7ce3 612sub whatever($) { }
e19a021b 613my $a = myrand + 4 ;
b5fb7ce3 614my $b = whatever + 4 ;
e19a021b 615EXPECT
b5fb7ce3 616Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
e19a021b 617########
0453d815 618# toke.c
e8ae98db
RGS
619use warnings "ambiguous";
620print for keys %+; # should not warn
621EXPECT
622########
623# toke.c
0453d815
PM
624sub fred {};
625-fred ;
626EXPECT
627Ambiguous use of -fred resolved as -&fred() at - line 3.
628########
629# toke.c
630$^W = 0 ;
631sub fred {} ;
632-fred ;
633{
4438c4b7 634 no warnings 'ambiguous' ;
0453d815 635 -fred ;
4438c4b7 636 use warnings 'ambiguous' ;
0453d815
PM
637 -fred ;
638}
639-fred ;
640EXPECT
641Ambiguous use of -fred resolved as -&fred() at - line 4.
642Ambiguous use of -fred resolved as -&fred() at - line 9.
643Ambiguous use of -fred resolved as -&fred() at - line 11.
644########
645# toke.c
646open FOO || time;
240d1b6f 647open local *FOO; # should be ok
0453d815
PM
648EXPECT
649Precedence problem: open FOO should be open(FOO) at - line 2.
650########
66fbe8fb
HS
651# toke.c (and [perl #16184])
652open FOO => "<&0"; close FOO;
653EXPECT
654########
0453d815
PM
655# toke.c
656$^W = 0 ;
657open FOO || time;
658{
e476b1b5 659 no warnings 'precedence' ;
0453d815 660 open FOO || time;
e476b1b5 661 use warnings 'precedence' ;
0453d815
PM
662 open FOO || time;
663}
664open FOO || time;
db3abe52 665open Foo::BAR; # this should not warn
0453d815
PM
666EXPECT
667Precedence problem: open FOO should be open(FOO) at - line 3.
668Precedence problem: open FOO should be open(FOO) at - line 8.
669Precedence problem: open FOO should be open(FOO) at - line 10.
670########
671# toke.c
672$^W = 0 ;
673*foo *foo ;
674{
4438c4b7 675 no warnings 'ambiguous' ;
0453d815 676 *foo *foo ;
4438c4b7 677 use warnings 'ambiguous' ;
0453d815
PM
678 *foo *foo ;
679}
680*foo *foo ;
681EXPECT
682Operator or semicolon missing before *foo at - line 3.
683Ambiguous use of * resolved as operator * at - line 3.
684Operator or semicolon missing before *foo at - line 8.
685Ambiguous use of * resolved as operator * at - line 8.
686Operator or semicolon missing before *foo at - line 10.
687Ambiguous use of * resolved as operator * at - line 10.
767a6a26
PM
688########
689# toke.c
e476b1b5 690use warnings 'misc' ;
767a6a26 691my $a = "\m" ;
e476b1b5 692no warnings 'misc' ;
767a6a26
PM
693$a = "\m" ;
694EXPECT
695Unrecognized escape \m passed through at - line 3.
696########
697# toke.c
698use warnings 'portable' ;
699my $a = 0b011111111111111111111111111111110 ;
700 $a = 0b011111111111111111111111111111111 ;
701 $a = 0b111111111111111111111111111111111 ;
702 $a = 0x0fffffffe ;
703 $a = 0x0ffffffff ;
704 $a = 0x1ffffffff ;
705 $a = 0037777777776 ;
706 $a = 0037777777777 ;
707 $a = 0047777777777 ;
708no warnings 'portable' ;
709 $a = 0b011111111111111111111111111111110 ;
710 $a = 0b011111111111111111111111111111111 ;
711 $a = 0b111111111111111111111111111111111 ;
712 $a = 0x0fffffffe ;
713 $a = 0x0ffffffff ;
714 $a = 0x1ffffffff ;
715 $a = 0037777777776 ;
716 $a = 0037777777777 ;
717 $a = 0047777777777 ;
718EXPECT
719Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
720Hexadecimal number > 0xffffffff non-portable at - line 8.
721Octal number > 037777777777 non-portable at - line 11.
722########
723# toke.c
724use warnings 'overflow' ;
725my $a = 0b011111111111111111111111111111110 ;
726 $a = 0b011111111111111111111111111111111 ;
15041a67 727 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
728 $a = 0x0fffffffe ;
729 $a = 0x0ffffffff ;
15041a67 730 $a = 0x10000000000000000 ;
767a6a26
PM
731 $a = 0037777777776 ;
732 $a = 0037777777777 ;
15041a67 733 $a = 002000000000000000000000;
767a6a26
PM
734no warnings 'overflow' ;
735 $a = 0b011111111111111111111111111111110 ;
736 $a = 0b011111111111111111111111111111111 ;
15041a67 737 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
738 $a = 0x0fffffffe ;
739 $a = 0x0ffffffff ;
15041a67 740 $a = 0x10000000000000000 ;
767a6a26
PM
741 $a = 0037777777776 ;
742 $a = 0037777777777 ;
15041a67 743 $a = 002000000000000000000000;
767a6a26
PM
744EXPECT
745Integer overflow in binary number at - line 5.
746Integer overflow in hexadecimal number at - line 8.
747Integer overflow in octal number at - line 11.
8593bda5
GS
748########
749# toke.c
ac206dc8
RGS
750BEGIN { $^C = 1; }
751use warnings 'misc';
752dump;
753CORE::dump;
754EXPECT
755dump() better written as CORE::dump() at - line 4.
756- syntax OK
757########
758# toke.c
759use warnings 'misc';
760use subs qw/dump/;
93f09d7b 761sub dump { print "no warning for overridden dump\n"; }
ac206dc8
RGS
762dump;
763EXPECT
93f09d7b 764no warning for overridden dump
ac206dc8
RGS
765########
766# toke.c
8593bda5
GS
767use warnings 'ambiguous';
768"@mjd_previously_unused_array";
769no warnings 'ambiguous';
770"@mjd_previously_unused_array";
771EXPECT
772Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
707afd92
MS
773########
774# toke.c
d8c55666 775# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
776use warnings 'regexp';
777"foo" =~ /foo/c;
64e578a2 778"foo" =~ /foo/cg;
4ac733c9
MJD
779no warnings 'regexp';
780"foo" =~ /foo/c;
64e578a2 781"foo" =~ /foo/cg;
4ac733c9
MJD
782EXPECT
783Use of /c modifier is meaningless without /g at - line 4.
784########
785# toke.c
d8c55666 786# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
787use warnings 'regexp';
788$_ = "ab" ;
789s/ab/ab/c;
64e578a2 790s/ab/ab/cg;
4ac733c9
MJD
791no warnings 'regexp';
792s/ab/ab/c;
64e578a2 793s/ab/ab/cg;
4ac733c9 794EXPECT
64e578a2
MJD
795Use of /c modifier is meaningless in s/// at - line 5.
796Use of /c modifier is meaningless in s/// at - line 6.
d8c55666
MJD
797########
798-wa
799# toke.c
800# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
801print "@F\n";
802EXPECT
803
804########
805-w
806# toke.c
807# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
808print "@F\n";
809EXPECT
810Possible unintended interpolation of @F in string at - line 4.
811Name "main::F" used only once: possible typo at - line 4.
812########
813-wa
814# toke.c
815# 20020414 mjd-perl-patch+@plover.com
816EXPECT
817
2710853f
MJD
818########
819# toke.c
820# 20020414 mjd-perl-patch+@plover.com
821# In 5.7.3, this emitted "Possible unintended interpolation" warnings
822use warnings 'ambiguous';
823$s = "(@-)(@+)";
824EXPECT
825
56da5a46
RGS
826########
827# toke.c
828# mandatory warning
829eval q/if ($a) { } elseif ($b) { }/;
830no warnings "syntax";
831eval q/if ($a) { } elseif ($b) { }/;
832EXPECT
833elseif should be elsif at (eval 1) line 1.
834########
835# toke.c
836# mandatory warning
837eval q/5 6/;
838no warnings "syntax";
839eval q/5 6/;
840EXPECT
841Number found where operator expected at (eval 1) line 1, near "5 6"
842 (Missing operator before 6?)
984200d0
YST
843########
844# toke.c
845use warnings "syntax";
846$_ = $a = 1;
847$a !=~ /1/;
848$a !=~ m#1#;
849$a !=~/1/;
850$a !=~ ?/?;
decca21c
YST
851$a !=~ y/1//;
852$a !=~ tr/1//;
853$a !=~ s/1//;
984200d0
YST
854$a != ~/1/;
855no warnings "syntax";
856$a !=~ /1/;
857$a !=~ m#1#;
858$a !=~/1/;
859$a !=~ ?/?;
decca21c
YST
860$a !=~ y/1//;
861$a !=~ tr/1//;
862$a !=~ s/1//;
984200d0
YST
863EXPECT
864!=~ should be !~ at - line 4.
865!=~ should be !~ at - line 5.
866!=~ should be !~ at - line 6.
867!=~ should be !~ at - line 7.
decca21c
YST
868!=~ should be !~ at - line 8.
869!=~ should be !~ at - line 9.
870!=~ should be !~ at - line 10.
1108974d
RGS
871########
872# toke.c
873our $foo :unique;
8e5dadda
NC
874sub pam :locked;
875sub glipp :locked {
876}
877sub whack_eth ($) : locked {
878}
d1d15184 879no warnings 'deprecated';
1108974d 880our $bar :unique;
8e5dadda
NC
881sub zapeth :locked;
882sub ker_plop :locked {
883}
884sub swa_a_p ($) : locked {
885}
1108974d 886EXPECT
d1d15184
NC
887Use of :unique is deprecated at - line 2.
888Use of :locked is deprecated at - line 3.
889Use of :locked is deprecated at - line 4.
890Use of :locked is deprecated at - line 6.
9e8d7757
RB
891########
892# toke.c
893use warnings "syntax";
894sub proto_after_array(@$);
895sub proto_after_arref(\@$);
896sub proto_after_arref2(\[@$]);
897sub proto_after_arref3(\[@$]_);
898sub proto_after_hash(%$);
899sub proto_after_hashref(\%$);
900sub proto_after_hashref2(\[%$]);
901sub underscore_last_pos($_);
902sub underscore2($_;$);
903sub underscore_fail($_$);
904sub underscore_after_at(@_);
905no warnings "syntax";
906sub proto_after_array(@$);
907sub proto_after_hash(%$);
908sub underscore_fail($_$);
909EXPECT
910Prototype after '@' for main::proto_after_array : @$ at - line 3.
911Prototype after '%' for main::proto_after_hash : %$ at - line 7.
aef2a98a 912Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
9e8d7757 913Prototype after '@' for main::underscore_after_at : @_ at - line 13.
77772344
B
914########
915# toke.c
916use warnings "ambiguous";
917"foo\nn" =~ /^foo$\n/;
918"foo\nn" =~ /^foo${\}n/;
919my $foo = qr/^foo$\n/;
920my $bar = qr/^foo${\}n/;
921no warnings "ambiguous";
922"foo\nn" =~ /^foo$\n/;
923"foo\nn" =~ /^foo${\}n/;
924my $foo = qr/^foo$\n/;
925my $bar = qr/^foo${\}n/;
926EXPECT
927Possible unintended interpolation of $\ in regex at - line 3.
928Possible unintended interpolation of $\ in regex at - line 5.
d83f38d8
NC
929########
930# toke.c
f0a2b745
KW
931use warnings 'syntax' ;
932my $a = "\o";
933my $a = "\o{";
934my $a = "\o{}";
935no warnings 'syntax' ;
936my $a = "\o";
937my $a = "\o{";
938my $a = "\o{}";
939EXPECT
940Missing braces on \o{} at - line 3, within string
941Missing right brace on \o{ at - line 4, within string
942Number with no digits at - line 5, within string
943BEGIN not safe after errors--compilation aborted at - line 6.
944########
945# toke.c
946use warnings 'digit' ;
947my $a = "\o{1238456}";
948no warnings 'digit' ;
949my $a = "\o{1238456}";
950EXPECT
951Non-octal character '8'. Resolved as "\o{123}" at - line 3.
725a61d7
Z
952########
953# toke.c
954use warnings;
955my $a = "foo";
956print $a =~ ?f? ? "yes\n" : "no\n" foreach 0..2;
957EXPECT
958Use of ?PATTERN? without explicit operator is deprecated at - line 4.
959yes
960no
961no
17a3df4c
KW
962########
963# toke.c
964use warnings;
965my $a = "\c{ack}";
966$a = "\c,";
967$a = "\c`";
968no warnings 'syntax';
969$a = "\c{ack}";
970$a = "\c,";
971$a = "\c`";
972no warnings 'deprecated';
973EXPECT
974"\c{" is deprecated and is more clearly written as ";" at - line 3.
975"\c," is more clearly written simply as "l" at - line 4.
976"\c`" is more clearly written simply as "\ " at - line 5.
977"\c{" is deprecated and is more clearly written as ";" at - line 7.
3955e1a9
KW
978########
979# toke.c
980use warnings 'syntax' ;
981my $a = qr/foo/du;
ff3f26d2 982$a = qr/foo/lai;
3955e1a9 983$a = qr/foo/lil;
ff3f26d2
KW
984$a = qr/foo/aia;
985$a = qr/foo/aaia;
3955e1a9
KW
986no warnings 'syntax' ;
987my $a = qr/foo/du;
988EXPECT
989Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
990Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
991Regexp modifier "/l" may not appear twice at - line 5, near "= "
ff3f26d2
KW
992Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
993BEGIN not safe after errors--compilation aborted at - line 8.
ba05d9aa
FC
994########
995# toke.c
996# [perl #4362]
997eval "print q\xabfoo";
998print "ok\n" if
999 $@ =~ /Can't find string terminator "\xab" anywhere before EOF/;
1000EXPECT
1001ok