memcpy has n o in it, as pinted ut by Sarathy.
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / 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      chmod() mode argument is missing initial 0 
50         chmod 3;
51
52      Possible attempt to separate words with commas 
53         @a = qw(a, b, c) ;
54
55      Possible attempt to put comments in qw() list 
56         @a = qw(a b # c) ;
57
58      umask: argument is missing initial 0 
59         umask 3;
60
61      %s (...) interpreted as function 
62         print ("")
63         printf ("")
64         sort ("")
65
66      Ambiguous use of %c{%s%s} resolved to %c%s%s 
67         $a = ${time[2]}
68         $a = ${time{2}}
69
70
71      Ambiguous use of %c{%s} resolved to %c%s
72         $a = ${time}
73         sub fred {} $a = ${fred}
74
75      Misplaced _ in number 
76         $a = 1_2;
77         $a = 1_2345_6;
78
79     Bareword \"%s\" refers to nonexistent package
80         $a = FRED:: ;
81
82     Ambiguous call resolved as CORE::%s(), qualify as such or use &
83         sub time {} 
84         my $a = time()
85
86     Unrecognized escape \\%c passed through
87         $a = "\m" ;
88
89     %s number > %s non-portable
90         my $a =  0b011111111111111111111111111111110 ;
91         $a =  0b011111111111111111111111111111111 ;
92         $a =  0b111111111111111111111111111111111 ;
93         $a =  0x0fffffffe ;
94         $a =  0x0ffffffff ;
95         $a =  0x1ffffffff ;
96         $a =  0037777777776 ;
97         $a =  0037777777777 ;
98         $a =  0047777777777 ;
99
100     Integer overflow in binary number
101         my $a =  0b011111111111111111111111111111110 ;
102         $a =  0b011111111111111111111111111111111 ;
103         $a =  0b111111111111111111111111111111111 ;
104         $a =  0x0fffffffe ;
105         $a =  0x0ffffffff ;
106         $a =  0x1ffffffff ;
107         $a =  0037777777776 ;
108         $a =  0037777777777 ;
109         $a =  0047777777777 ;
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 use warnings 'deprecated' ;
129 format STDOUT =
130 @<<<  @|||  @>>>  @>>>
131 $a    $b    "abc" 'def'
132 .
133 no warnings 'deprecated' ;
134 format STDOUT =
135 @<<<  @|||  @>>>  @>>>
136 $a    $b    "abc" 'def'
137 .
138 EXPECT
139 Use of comma-less variable list is deprecated at - line 5.
140 Use of comma-less variable list is deprecated at - line 5.
141 Use of comma-less variable list is deprecated at - line 5.
142 ########
143 # toke.c
144 use warnings 'deprecated' ;
145 $a = <<;
146
147 no warnings 'deprecated' ;
148 $a = <<;
149
150 EXPECT
151 Use of bare << to mean <<"" is deprecated at - line 3.
152 ########
153 # toke.c
154 use warnings 'syntax' ;
155 s/(abc)/\1/;
156 no warnings 'syntax' ;
157 s/(abc)/\1/;
158 EXPECT
159 \1 better written as $1 at - line 3.
160 ########
161 # toke.c
162 use warnings 'semicolon' ;
163 $a = 1
164 &time ;
165 no warnings 'semicolon' ;
166 $a = 1
167 &time ;
168 EXPECT
169 Semicolon seems to be missing at - line 3.
170 ########
171 # toke.c
172 BEGIN {
173     # Scalars leaked: due to syntax errors
174     $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
175 }
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 7.
189 Reversed -= operator at - line 8.
190 Reversed *= operator at - line 9.
191 Reversed %= operator at - line 10.
192 Reversed &= operator at - line 11.
193 Reversed .= operator at - line 12.
194 Reversed ^= operator at - line 13.
195 Reversed |= operator at - line 14.
196 Reversed <= operator at - line 15.
197 syntax error at - line 12, near "=."
198 syntax error at - line 13, near "=^"
199 syntax error at - line 14, near "=|"
200 Unterminated <> operator at - line 15.
201 ########
202 # toke.c
203 BEGIN {
204     # Scalars leaked: due to syntax errors
205     $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
206 }
207 no warnings 'syntax' ;
208 my $a =+ 2 ;
209 $a =- 2 ;
210 $a =* 2 ;
211 $a =% 2 ;
212 $a =& 2 ;
213 $a =. 2 ;
214 $a =^ 2 ;
215 $a =| 2 ;
216 $a =< 2 ;
217 $a =/ 2 ;
218 EXPECT
219 syntax error at - line 12, near "=."
220 syntax error at - line 13, near "=^"
221 syntax error at - line 14, near "=|"
222 Unterminated <> operator at - line 15.
223 ########
224 # toke.c
225 use warnings 'syntax' ;
226 my $a = $a[1,2] ;
227 no warnings 'syntax' ;
228 my $a = $a[1,2] ;
229 EXPECT
230 Multidimensional syntax $a[1,2] not supported at - line 3.
231 ########
232 # toke.c
233 use warnings 'syntax' ;
234 sub fred {} ; $SIG{TERM} = fred;
235 no warnings 'syntax' ;
236 $SIG{TERM} = fred;
237 EXPECT
238 You need to quote "fred" at - line 3.
239 ########
240 # toke.c
241 use warnings 'syntax' ;
242 @a[3] = 2;
243 @a{3} = 2;
244 no warnings 'syntax' ;
245 @a[3] = 2;
246 @a{3} = 2;
247 EXPECT
248 Scalar value @a[3] better written as $a[3] at - line 3.
249 Scalar value @a{3} better written as $a{3} at - line 4.
250 ########
251 # toke.c
252 use warnings 'syntax' ;
253 $_ = "ab" ; 
254 s/(ab)/\1/e;
255 no warnings 'syntax' ;
256 $_ = "ab" ; 
257 s/(ab)/\1/e;
258 EXPECT
259 Can't use \1 to mean $1 in expression at - line 4.
260 ########
261 # toke.c
262 use warnings 'reserved' ;
263 $a = abc;
264 $a = { def
265
266 => 1 };
267 no warnings 'reserved' ;
268 $a = abc;
269 EXPECT
270 Unquoted string "abc" may clash with future reserved word at - line 3.
271 ########
272 # toke.c
273 use warnings 'chmod' ;
274 chmod 3;
275 no warnings 'chmod' ;
276 chmod 3;
277 EXPECT
278 chmod() mode argument is missing initial 0 at - line 3.
279 ########
280 # toke.c
281 use warnings 'qw' ;
282 @a = qw(a, b, c) ;
283 no warnings 'qw' ;
284 @a = qw(a, b, c) ;
285 EXPECT
286 Possible attempt to separate words with commas at - line 3.
287 ########
288 # toke.c
289 use warnings 'qw' ;
290 @a = qw(a b #) ;
291 no warnings 'qw' ;
292 @a = qw(a b #) ;
293 EXPECT
294 Possible attempt to put comments in qw() list at - line 3.
295 ########
296 # toke.c
297 use warnings 'umask' ;
298 umask 3;
299 no warnings 'umask' ;
300 umask 3;
301 EXPECT
302 umask: argument is missing initial 0 at - line 3.
303 ########
304 # toke.c
305 use warnings 'syntax' ;
306 print ("")
307 EXPECT
308 print (...) interpreted as function at - line 3.
309 ########
310 # toke.c
311 no warnings 'syntax' ;
312 print ("")
313 EXPECT
314
315 ########
316 # toke.c
317 use warnings 'syntax' ;
318 printf ("")
319 EXPECT
320 printf (...) interpreted as function at - line 3.
321 ########
322 # toke.c
323 no warnings 'syntax' ;
324 printf ("")
325 EXPECT
326
327 ########
328 # toke.c
329 use warnings 'syntax' ;
330 sort ("")
331 EXPECT
332 sort (...) interpreted as function at - line 3.
333 ########
334 # toke.c
335 no warnings 'syntax' ;
336 sort ("")
337 EXPECT
338
339 ########
340 # toke.c
341 use warnings 'ambiguous' ;
342 $a = ${time[2]};
343 no warnings 'ambiguous' ;
344 $a = ${time[2]};
345 EXPECT
346 Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
347 ########
348 # toke.c
349 use warnings 'ambiguous' ;
350 $a = ${time{2}};
351 EXPECT
352 Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
353 ########
354 # toke.c
355 no warnings 'ambiguous' ;
356 $a = ${time{2}};
357 EXPECT
358
359 ########
360 # toke.c
361 use warnings 'ambiguous' ;
362 $a = ${time} ;
363 no warnings 'ambiguous' ;
364 $a = ${time} ;
365 EXPECT
366 Ambiguous use of ${time} resolved to $time at - line 3.
367 ########
368 # toke.c
369 use warnings 'ambiguous' ;
370 sub fred {}
371 $a = ${fred} ;
372 no warnings 'ambiguous' ;
373 $a = ${fred} ;
374 EXPECT
375 Ambiguous use of ${fred} resolved to $fred at - line 4.
376 ########
377 # toke.c
378 use warnings 'syntax' ;
379 $a = 1_2;
380 $a = 1_2345_6;
381 no warnings 'syntax' ;
382 $a = 1_2;
383 $a = 1_2345_6;
384 EXPECT
385 Misplaced _ in number at - line 3.
386 Misplaced _ in number at - line 4.
387 Misplaced _ in number at - line 4.
388 ########
389 # toke.c
390 use warnings 'bareword' ;
391 #line 25 "bar"
392 $a = FRED:: ;
393 no warnings 'bareword' ;
394 #line 25 "bar"
395 $a = FRED:: ;
396 EXPECT
397 Bareword "FRED::" refers to nonexistent package at bar line 25.
398 ########
399 # toke.c
400 use warnings 'ambiguous' ;
401 sub time {}
402 my $a = time() ;
403 no warnings 'ambiguous' ;
404 my $b = time() ;
405 EXPECT
406 Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
407 ########
408 # toke.c
409 use warnings ;
410 eval <<'EOE';
411 #  line 30 "foo"
412 warn "yelp";
413 {
414   $_ = " \x{123} " ;
415 }
416 EOE
417 EXPECT
418 yelp at foo line 30.
419 ########
420 # toke.c
421 my $a = rand + 4 ;
422 EXPECT
423 Warning: Use of "rand" without parens is ambiguous at - line 2.
424 ########
425 # toke.c
426 $^W = 0 ;
427 my $a = rand + 4 ;
428 {
429     no warnings 'ambiguous' ;
430     $a = rand + 4 ;
431     use warnings 'ambiguous' ;
432     $a = rand + 4 ;
433 }
434 $a = rand + 4 ;
435 EXPECT
436 Warning: Use of "rand" without parens is ambiguous at - line 3.
437 Warning: Use of "rand" without parens is ambiguous at - line 8.
438 Warning: Use of "rand" without parens is ambiguous at - line 10.
439 ########
440 # toke.c
441 sub fred {};
442 -fred ;
443 EXPECT
444 Ambiguous use of -fred resolved as -&fred() at - line 3.
445 ########
446 # toke.c
447 $^W = 0 ;
448 sub fred {} ;
449 -fred ;
450 {
451     no warnings 'ambiguous' ;
452     -fred ;
453     use warnings 'ambiguous' ;
454     -fred ;
455 }
456 -fred ;
457 EXPECT
458 Ambiguous use of -fred resolved as -&fred() at - line 4.
459 Ambiguous use of -fred resolved as -&fred() at - line 9.
460 Ambiguous use of -fred resolved as -&fred() at - line 11.
461 ########
462 # toke.c
463 open FOO || time;
464 EXPECT
465 Precedence problem: open FOO should be open(FOO) at - line 2.
466 ########
467 # toke.c
468 $^W = 0 ;
469 open FOO || time;
470 {
471     no warnings 'precedence' ;
472     open FOO || time;
473     use warnings 'precedence' ;
474     open FOO || time;
475 }
476 open FOO || time;
477 EXPECT
478 Precedence problem: open FOO should be open(FOO) at - line 3.
479 Precedence problem: open FOO should be open(FOO) at - line 8.
480 Precedence problem: open FOO should be open(FOO) at - line 10.
481 ########
482 # toke.c
483 $^W = 0 ;
484 *foo *foo ;
485 {
486     no warnings 'ambiguous' ;
487     *foo *foo ;
488     use warnings 'ambiguous' ;
489     *foo *foo ;
490 }
491 *foo *foo ;
492 EXPECT
493 Operator or semicolon missing before *foo at - line 3.
494 Ambiguous use of * resolved as operator * at - line 3.
495 Operator or semicolon missing before *foo at - line 8.
496 Ambiguous use of * resolved as operator * at - line 8.
497 Operator or semicolon missing before *foo at - line 10.
498 Ambiguous use of * resolved as operator * at - line 10.
499 ########
500 # toke.c
501 use warnings 'misc' ;
502 my $a = "\m" ;
503 no warnings 'misc' ;
504 $a = "\m" ;
505 EXPECT
506 Unrecognized escape \m passed through at - line 3.
507 ########
508 # toke.c
509 use warnings 'portable' ;
510 my $a =  0b011111111111111111111111111111110 ;
511    $a =  0b011111111111111111111111111111111 ;
512    $a =  0b111111111111111111111111111111111 ;
513    $a =  0x0fffffffe ;
514    $a =  0x0ffffffff ;
515    $a =  0x1ffffffff ;
516    $a =  0037777777776 ;
517    $a =  0037777777777 ;
518    $a =  0047777777777 ;
519 no warnings 'portable' ;
520    $a =  0b011111111111111111111111111111110 ;
521    $a =  0b011111111111111111111111111111111 ;
522    $a =  0b111111111111111111111111111111111 ;
523    $a =  0x0fffffffe ;
524    $a =  0x0ffffffff ;
525    $a =  0x1ffffffff ;
526    $a =  0037777777776 ;
527    $a =  0037777777777 ;
528    $a =  0047777777777 ;
529 EXPECT
530 Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
531 Hexadecimal number > 0xffffffff non-portable at - line 8.
532 Octal number > 037777777777 non-portable at - line 11.
533 ########
534 # toke.c
535 use warnings 'overflow' ;
536 my $a =  0b011111111111111111111111111111110 ;
537    $a =  0b011111111111111111111111111111111 ;
538    $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
539    $a =  0x0fffffffe ;
540    $a =  0x0ffffffff ;
541    $a =  0x10000000000000000 ;
542    $a =  0037777777776 ;
543    $a =  0037777777777 ;
544    $a =  002000000000000000000000;
545 no warnings 'overflow' ;
546    $a =  0b011111111111111111111111111111110 ;
547    $a =  0b011111111111111111111111111111111 ;
548    $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
549    $a =  0x0fffffffe ;
550    $a =  0x0ffffffff ;
551    $a =  0x10000000000000000 ;
552    $a =  0037777777776 ;
553    $a =  0037777777777 ;
554    $a =  002000000000000000000000;
555 EXPECT
556 Integer overflow in binary number at - line 5.
557 Integer overflow in hexadecimal number at - line 8.
558 Integer overflow in octal number at - line 11.
559 ########
560 # toke.c
561 use warnings 'ambiguous';
562 "@mjd_previously_unused_array";        
563 no warnings 'ambiguous';
564 "@mjd_previously_unused_array";        
565 EXPECT
566 Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.