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