This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
dquote_static.c: Add comment
[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' ;
599cee73 278@a = qw(a b #) ;
e476b1b5 279no warnings 'qw' ;
0453d815 280@a = qw(a b #) ;
599cee73
PM
281EXPECT
282Possible attempt to put comments in qw() list at - line 3.
283########
284# toke.c
4438c4b7 285use warnings 'syntax' ;
b1439985
RGS
286print ("");
287print ("") and $x = 1;
288print ("") or die;
289print ("") // die;
290print (1+2) * 3 if 0; # only this one should warn
291print (1+2) if 0;
599cee73 292EXPECT
b1439985 293print (...) interpreted as function at - line 7.
599cee73
PM
294########
295# toke.c
4438c4b7 296no warnings 'syntax' ;
0453d815
PM
297print ("")
298EXPECT
299
300########
301# toke.c
4438c4b7 302use warnings 'syntax' ;
b1439985
RGS
303printf ("");
304printf ("") . '';
599cee73 305EXPECT
b1439985 306printf (...) interpreted as function at - line 4.
599cee73
PM
307########
308# toke.c
4438c4b7 309no warnings 'syntax' ;
0453d815
PM
310printf ("")
311EXPECT
312
313########
314# toke.c
4438c4b7 315use warnings 'syntax' ;
b1439985
RGS
316sort ("");
317sort ("") . '';
599cee73 318EXPECT
b1439985 319sort (...) interpreted as function at - line 4.
599cee73
PM
320########
321# toke.c
4438c4b7 322no warnings 'syntax' ;
0453d815
PM
323sort ("")
324EXPECT
325
326########
327# toke.c
4438c4b7 328use warnings 'ambiguous' ;
599cee73 329$a = ${time[2]};
4438c4b7 330no warnings 'ambiguous' ;
0453d815 331$a = ${time[2]};
599cee73
PM
332EXPECT
333Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
334########
335# toke.c
4438c4b7 336use warnings 'ambiguous' ;
599cee73
PM
337$a = ${time{2}};
338EXPECT
339Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
340########
341# toke.c
4438c4b7 342no warnings 'ambiguous' ;
0453d815
PM
343$a = ${time{2}};
344EXPECT
345
346########
347# toke.c
4438c4b7 348use warnings 'ambiguous' ;
599cee73 349$a = ${time} ;
4438c4b7 350no warnings 'ambiguous' ;
0453d815 351$a = ${time} ;
599cee73
PM
352EXPECT
353Ambiguous use of ${time} resolved to $time at - line 3.
354########
355# toke.c
4438c4b7 356use warnings 'ambiguous' ;
599cee73
PM
357sub fred {}
358$a = ${fred} ;
4438c4b7 359no warnings 'ambiguous' ;
0453d815 360$a = ${fred} ;
599cee73
PM
361EXPECT
362Ambiguous use of ${fred} resolved to $fred at - line 4.
363########
364# toke.c
4438c4b7 365use warnings 'syntax' ;
7fd134d9
JH
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
2bea9a37
JH
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
7fd134d9
JH
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
b3b48e3e
JH
403$a = 1__23; print "$a\n"; # 40
404$a = 12.3__4; print "$a\n"; # 41
2bea9a37 405$a = 12.34e1__2; printf("%.0f\n", $a); # 42
4438c4b7 406no warnings 'syntax' ;
7fd134d9
JH
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";
2bea9a37
JH
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);
7fd134d9
JH
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";
b3b48e3e
JH
444$a = 1__23; print "$a\n";
445$a = 12.3__4; print "$a\n";
2bea9a37 446$a = 12.34e1__2; printf("%.0f\n", $a);
599cee73 447EXPECT
fbfa96bd 448OPTIONS regex
928753ea 449Misplaced _ in number at - line 6.
928753ea 450Misplaced _ in number at - line 11.
7fd134d9 451Misplaced _ in number at - line 16.
928753ea 452Misplaced _ in number at - line 17.
7fd134d9 453Misplaced _ in number at - line 20.
928753ea 454Misplaced _ in number at - line 21.
7fd134d9
JH
455Misplaced _ in number at - line 24.
456Misplaced _ in number at - line 25.
457Misplaced _ in number at - line 28.
458Misplaced _ in number at - line 29.
459Misplaced _ in number at - line 31.
460Misplaced _ in number at - line 32.
461Misplaced _ in number at - line 33.
462Misplaced _ in number at - line 35.
463Misplaced _ in number at - line 36.
464Misplaced _ in number at - line 37.
465Misplaced _ in number at - line 39.
b3b48e3e
JH
466Misplaced _ in number at - line 40.
467Misplaced _ in number at - line 41.
468Misplaced _ in number at - line 42.
928753ea
JH
469_123
470123
928753ea 471123
7fd134d9
JH
472123
473123
474_123
475123
476123
477123
478-123
479-_123
480-123
481-123
482-123
483123.456
484123.456
485123.456
486123.456
487123.456
488123.456
489123.456
490123.456
491-123.456
492-123.456
493-123.456
494-123.456
495123456000000000
496123456000000000
497123456000000000
498123456000000000
499123456000000000
500123456000000000
501123456000000000
fbfa96bd
NIS
5021.23456e-0?10
5031.23456e-0?10
5041.23456e-0?10
5051.23456e-0?10
b3b48e3e
JH
506123
50712.34
50812340000000000
7fd134d9
JH
509_123
510123
511123
512123
513123
514_123
515123
516123
517123
518-123
519-_123
520-123
521-123
522-123
523123.456
524123.456
525123.456
526123.456
527123.456
928753ea
JH
528123.456
529123.456
928753ea 530123.456
7fd134d9
JH
531-123.456
532-123.456
533-123.456
534-123.456
535123456000000000
536123456000000000
537123456000000000
538123456000000000
539123456000000000
540123456000000000
541123456000000000
fbfa96bd
NIS
5421.23456e-0?10
5431.23456e-0?10
5441.23456e-0?10
5451.23456e-0?10
b3b48e3e
JH
546123
54712.34
54812340000000000
599cee73
PM
549########
550# toke.c
e476b1b5 551use warnings 'bareword' ;
60e6418e 552#line 25 "bar"
599cee73 553$a = FRED:: ;
e476b1b5 554no warnings 'bareword' ;
0453d815
PM
555#line 25 "bar"
556$a = FRED:: ;
599cee73 557EXPECT
60e6418e 558Bareword "FRED::" refers to nonexistent package at bar line 25.
599cee73
PM
559########
560# toke.c
4438c4b7 561use warnings 'ambiguous' ;
599cee73 562sub time {}
0453d815 563my $a = time() ;
4438c4b7 564no warnings 'ambiguous' ;
0453d815 565my $b = time() ;
599cee73
PM
566EXPECT
567Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
568########
569# toke.c
26d16222 570use warnings ;
0453d815 571eval <<'EOE';
df0deb90
GS
572# line 30 "foo"
573warn "yelp";
0453d815 574{
0453d815
PM
575 $_ = " \x{123} " ;
576}
577EOE
578EXPECT
df0deb90 579yelp at foo line 30.
0453d815
PM
580########
581# toke.c
0453d815
PM
582my $a = rand + 4 ;
583EXPECT
2d5ccbba 584Warning: Use of "rand" without parentheses is ambiguous at - line 2.
0453d815
PM
585########
586# toke.c
587$^W = 0 ;
588my $a = rand + 4 ;
589{
4438c4b7 590 no warnings 'ambiguous' ;
0453d815 591 $a = rand + 4 ;
4438c4b7 592 use warnings 'ambiguous' ;
0453d815
PM
593 $a = rand + 4 ;
594}
595$a = rand + 4 ;
596EXPECT
2d5ccbba
IT
597Warning: Use of "rand" without parentheses is ambiguous at - line 3.
598Warning: Use of "rand" without parentheses is ambiguous at - line 8.
599Warning: Use of "rand" without parentheses is ambiguous at - line 10.
0453d815
PM
600########
601# toke.c
e8ae98db
RGS
602use warnings "ambiguous";
603print for keys %+; # should not warn
604EXPECT
605########
606# toke.c
0453d815
PM
607sub fred {};
608-fred ;
609EXPECT
610Ambiguous use of -fred resolved as -&fred() at - line 3.
611########
612# toke.c
613$^W = 0 ;
614sub fred {} ;
615-fred ;
616{
4438c4b7 617 no warnings 'ambiguous' ;
0453d815 618 -fred ;
4438c4b7 619 use warnings 'ambiguous' ;
0453d815
PM
620 -fred ;
621}
622-fred ;
623EXPECT
624Ambiguous use of -fred resolved as -&fred() at - line 4.
625Ambiguous use of -fred resolved as -&fred() at - line 9.
626Ambiguous use of -fred resolved as -&fred() at - line 11.
627########
628# toke.c
629open FOO || time;
630EXPECT
631Precedence problem: open FOO should be open(FOO) at - line 2.
632########
66fbe8fb
HS
633# toke.c (and [perl #16184])
634open FOO => "<&0"; close FOO;
635EXPECT
636########
0453d815
PM
637# toke.c
638$^W = 0 ;
639open FOO || time;
640{
e476b1b5 641 no warnings 'precedence' ;
0453d815 642 open FOO || time;
e476b1b5 643 use warnings 'precedence' ;
0453d815
PM
644 open FOO || time;
645}
646open FOO || time;
647EXPECT
648Precedence problem: open FOO should be open(FOO) at - line 3.
649Precedence problem: open FOO should be open(FOO) at - line 8.
650Precedence problem: open FOO should be open(FOO) at - line 10.
651########
652# toke.c
653$^W = 0 ;
654*foo *foo ;
655{
4438c4b7 656 no warnings 'ambiguous' ;
0453d815 657 *foo *foo ;
4438c4b7 658 use warnings 'ambiguous' ;
0453d815
PM
659 *foo *foo ;
660}
661*foo *foo ;
662EXPECT
663Operator or semicolon missing before *foo at - line 3.
664Ambiguous use of * resolved as operator * at - line 3.
665Operator or semicolon missing before *foo at - line 8.
666Ambiguous use of * resolved as operator * at - line 8.
667Operator or semicolon missing before *foo at - line 10.
668Ambiguous use of * resolved as operator * at - line 10.
767a6a26
PM
669########
670# toke.c
e476b1b5 671use warnings 'misc' ;
767a6a26 672my $a = "\m" ;
e476b1b5 673no warnings 'misc' ;
767a6a26
PM
674$a = "\m" ;
675EXPECT
676Unrecognized escape \m passed through at - line 3.
677########
678# toke.c
679use warnings 'portable' ;
680my $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 ;
689no 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 ;
699EXPECT
700Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
701Hexadecimal number > 0xffffffff non-portable at - line 8.
702Octal number > 037777777777 non-portable at - line 11.
703########
704# toke.c
705use warnings 'overflow' ;
706my $a = 0b011111111111111111111111111111110 ;
707 $a = 0b011111111111111111111111111111111 ;
15041a67 708 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
709 $a = 0x0fffffffe ;
710 $a = 0x0ffffffff ;
15041a67 711 $a = 0x10000000000000000 ;
767a6a26
PM
712 $a = 0037777777776 ;
713 $a = 0037777777777 ;
15041a67 714 $a = 002000000000000000000000;
767a6a26
PM
715no warnings 'overflow' ;
716 $a = 0b011111111111111111111111111111110 ;
717 $a = 0b011111111111111111111111111111111 ;
15041a67 718 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
719 $a = 0x0fffffffe ;
720 $a = 0x0ffffffff ;
15041a67 721 $a = 0x10000000000000000 ;
767a6a26
PM
722 $a = 0037777777776 ;
723 $a = 0037777777777 ;
15041a67 724 $a = 002000000000000000000000;
767a6a26
PM
725EXPECT
726Integer overflow in binary number at - line 5.
727Integer overflow in hexadecimal number at - line 8.
728Integer overflow in octal number at - line 11.
8593bda5
GS
729########
730# toke.c
ac206dc8
RGS
731BEGIN { $^C = 1; }
732use warnings 'misc';
733dump;
734CORE::dump;
735EXPECT
736dump() better written as CORE::dump() at - line 4.
737- syntax OK
738########
739# toke.c
740use warnings 'misc';
741use subs qw/dump/;
93f09d7b 742sub dump { print "no warning for overridden dump\n"; }
ac206dc8
RGS
743dump;
744EXPECT
93f09d7b 745no warning for overridden dump
ac206dc8
RGS
746########
747# toke.c
8593bda5
GS
748use warnings 'ambiguous';
749"@mjd_previously_unused_array";
750no warnings 'ambiguous';
751"@mjd_previously_unused_array";
752EXPECT
753Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
707afd92
MS
754########
755# toke.c
d8c55666 756# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
757use warnings 'regexp';
758"foo" =~ /foo/c;
64e578a2 759"foo" =~ /foo/cg;
4ac733c9
MJD
760no warnings 'regexp';
761"foo" =~ /foo/c;
64e578a2 762"foo" =~ /foo/cg;
4ac733c9
MJD
763EXPECT
764Use of /c modifier is meaningless without /g at - line 4.
765########
766# toke.c
d8c55666 767# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
768use warnings 'regexp';
769$_ = "ab" ;
770s/ab/ab/c;
64e578a2 771s/ab/ab/cg;
4ac733c9
MJD
772no warnings 'regexp';
773s/ab/ab/c;
64e578a2 774s/ab/ab/cg;
4ac733c9 775EXPECT
64e578a2
MJD
776Use of /c modifier is meaningless in s/// at - line 5.
777Use of /c modifier is meaningless in s/// at - line 6.
d8c55666
MJD
778########
779-wa
780# toke.c
781# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
782print "@F\n";
783EXPECT
784
785########
786-w
787# toke.c
788# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
789print "@F\n";
790EXPECT
791Possible unintended interpolation of @F in string at - line 4.
792Name "main::F" used only once: possible typo at - line 4.
793########
794-wa
795# toke.c
796# 20020414 mjd-perl-patch+@plover.com
797EXPECT
798
2710853f
MJD
799########
800# toke.c
801# 20020414 mjd-perl-patch+@plover.com
802# In 5.7.3, this emitted "Possible unintended interpolation" warnings
803use warnings 'ambiguous';
804$s = "(@-)(@+)";
805EXPECT
806
56da5a46
RGS
807########
808# toke.c
809# mandatory warning
810eval q/if ($a) { } elseif ($b) { }/;
811no warnings "syntax";
812eval q/if ($a) { } elseif ($b) { }/;
813EXPECT
814elseif should be elsif at (eval 1) line 1.
815########
816# toke.c
817# mandatory warning
818eval q/5 6/;
819no warnings "syntax";
820eval q/5 6/;
821EXPECT
822Number found where operator expected at (eval 1) line 1, near "5 6"
823 (Missing operator before 6?)
984200d0
YST
824########
825# toke.c
826use warnings "syntax";
827$_ = $a = 1;
828$a !=~ /1/;
829$a !=~ m#1#;
830$a !=~/1/;
831$a !=~ ?/?;
decca21c
YST
832$a !=~ y/1//;
833$a !=~ tr/1//;
834$a !=~ s/1//;
984200d0
YST
835$a != ~/1/;
836no warnings "syntax";
837$a !=~ /1/;
838$a !=~ m#1#;
839$a !=~/1/;
840$a !=~ ?/?;
decca21c
YST
841$a !=~ y/1//;
842$a !=~ tr/1//;
843$a !=~ s/1//;
984200d0
YST
844EXPECT
845!=~ should be !~ at - line 4.
846!=~ should be !~ at - line 5.
847!=~ should be !~ at - line 6.
848!=~ should be !~ at - line 7.
decca21c
YST
849!=~ should be !~ at - line 8.
850!=~ should be !~ at - line 9.
851!=~ should be !~ at - line 10.
1108974d
RGS
852########
853# toke.c
854our $foo :unique;
8e5dadda
NC
855sub pam :locked;
856sub glipp :locked {
857}
858sub whack_eth ($) : locked {
859}
d1d15184 860no warnings 'deprecated';
1108974d 861our $bar :unique;
8e5dadda
NC
862sub zapeth :locked;
863sub ker_plop :locked {
864}
865sub swa_a_p ($) : locked {
866}
1108974d 867EXPECT
d1d15184
NC
868Use of :unique is deprecated at - line 2.
869Use of :locked is deprecated at - line 3.
870Use of :locked is deprecated at - line 4.
871Use of :locked is deprecated at - line 6.
9e8d7757
RB
872########
873# toke.c
874use warnings "syntax";
875sub proto_after_array(@$);
876sub proto_after_arref(\@$);
877sub proto_after_arref2(\[@$]);
878sub proto_after_arref3(\[@$]_);
879sub proto_after_hash(%$);
880sub proto_after_hashref(\%$);
881sub proto_after_hashref2(\[%$]);
882sub underscore_last_pos($_);
883sub underscore2($_;$);
884sub underscore_fail($_$);
885sub underscore_after_at(@_);
886no warnings "syntax";
887sub proto_after_array(@$);
888sub proto_after_hash(%$);
889sub underscore_fail($_$);
890EXPECT
891Prototype after '@' for main::proto_after_array : @$ at - line 3.
892Prototype after '%' for main::proto_after_hash : %$ at - line 7.
aef2a98a 893Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
9e8d7757 894Prototype after '@' for main::underscore_after_at : @_ at - line 13.
77772344
B
895########
896# toke.c
897use warnings "ambiguous";
898"foo\nn" =~ /^foo$\n/;
899"foo\nn" =~ /^foo${\}n/;
900my $foo = qr/^foo$\n/;
901my $bar = qr/^foo${\}n/;
902no warnings "ambiguous";
903"foo\nn" =~ /^foo$\n/;
904"foo\nn" =~ /^foo${\}n/;
905my $foo = qr/^foo$\n/;
906my $bar = qr/^foo${\}n/;
907EXPECT
908Possible unintended interpolation of $\ in regex at - line 3.
909Possible unintended interpolation of $\ in regex at - line 5.
d83f38d8
NC
910########
911# toke.c
f0a2b745
KW
912use warnings 'syntax' ;
913my $a = "\o";
914my $a = "\o{";
915my $a = "\o{}";
916no warnings 'syntax' ;
917my $a = "\o";
918my $a = "\o{";
919my $a = "\o{}";
920EXPECT
921Missing braces on \o{} at - line 3, within string
922Missing right brace on \o{ at - line 4, within string
923Number with no digits at - line 5, within string
924BEGIN not safe after errors--compilation aborted at - line 6.
925########
926# toke.c
927use warnings 'digit' ;
928my $a = "\o{1238456}";
929no warnings 'digit' ;
930my $a = "\o{1238456}";
931EXPECT
932Non-octal character '8'. Resolved as "\o{123}" at - line 3.
725a61d7
Z
933########
934# toke.c
935use warnings;
936my $a = "foo";
937print $a =~ ?f? ? "yes\n" : "no\n" foreach 0..2;
938EXPECT
939Use of ?PATTERN? without explicit operator is deprecated at - line 4.
940yes
941no
942no