2 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
3 # This file was created by warnings.pl
4 # Any changes made here will be lost.
13 warnings - Perl pragma to control optional warnings
23 use warnings::register;
24 if (warnings::enabled()) {
25 warnings::warn("some warning");
28 if (warnings::enabled("void")) {
29 warnings::warn("void", "some warning");
32 if (warnings::enabled($object)) {
33 warnings::warn($object, "some warning");
36 warnings::warnif("some warning");
37 warnings::warnif("void", "some warning");
38 warnings::warnif($object, "some warning");
42 If no import list is supplied, all possible warnings are either enabled
45 A number of functions are provided to assist module authors.
49 =item use warnings::register
51 Creates a new warnings category with the same name as the package where
52 the call to the pragma is used.
54 =item warnings::enabled()
56 Use the warnings category with the same name as the current package.
58 Return TRUE if that warnings category is enabled in the calling module.
59 Otherwise returns FALSE.
61 =item warnings::enabled($category)
63 Return TRUE if the warnings category, C<$category>, is enabled in the
65 Otherwise returns FALSE.
67 =item warnings::enabled($object)
69 Use the name of the class for the object reference, C<$object>, as the
72 Return TRUE if that warnings category is enabled in the first scope
73 where the object is used.
74 Otherwise returns FALSE.
76 =item warnings::warn($message)
78 Print C<$message> to STDERR.
80 Use the warnings category with the same name as the current package.
82 If that warnings category has been set to "FATAL" in the calling module
83 then die. Otherwise return.
85 =item warnings::warn($category, $message)
87 Print C<$message> to STDERR.
89 If the warnings category, C<$category>, has been set to "FATAL" in the
90 calling module then die. Otherwise return.
92 =item warnings::warn($object, $message)
94 Print C<$message> to STDERR.
96 Use the name of the class for the object reference, C<$object>, as the
99 If that warnings category has been set to "FATAL" in the scope where C<$object>
100 is first used then die. Otherwise return.
103 =item warnings::warnif($message)
107 if (warnings::enabled())
108 { warnings::warn($message) }
110 =item warnings::warnif($category, $message)
114 if (warnings::enabled($category))
115 { warnings::warn($category, $message) }
117 =item warnings::warnif($object, $message)
121 if (warnings::enabled($object))
122 { warnings::warn($object, $message) }
126 See L<perlmodlib/Pragmatic Modules> and L<perllexwarn>.
134 # Warnings Categories added in Perl 5.008
177 'uninitialized' => 82,
186 'all' => "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15", # [0..46]
187 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00", # [29]
188 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00", # [30]
189 'closed' => "\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6]
190 'closure' => "\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1]
191 'debugging' => "\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00", # [22]
192 'deprecated' => "\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [2]
193 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00", # [31]
194 'exec' => "\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7]
195 'exiting' => "\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3]
196 'glob' => "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4]
197 'inplace' => "\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00", # [23]
198 'internal' => "\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00", # [24]
199 'io' => "\x00\x54\x55\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [5..11]
200 'layer' => "\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8]
201 'malloc' => "\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00", # [25]
202 'misc' => "\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00", # [12]
203 'newline' => "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9]
204 'numeric' => "\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00", # [13]
205 'once' => "\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00", # [14]
206 'overflow' => "\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00", # [15]
207 'pack' => "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00", # [16]
208 'parenthesis' => "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00", # [32]
209 'pipe' => "\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [10]
210 'portable' => "\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00", # [17]
211 'precedence' => "\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00", # [33]
212 'printf' => "\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00", # [34]
213 'prototype' => "\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00", # [35]
214 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00", # [36]
215 'recursion' => "\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00", # [18]
216 'redefine' => "\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00", # [19]
217 'regexp' => "\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00", # [20]
218 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00", # [37]
219 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00", # [38]
220 'severe' => "\x00\x00\x00\x00\x00\x54\x05\x00\x00\x00\x00\x00", # [21..25]
221 'signal' => "\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00", # [26]
222 'substr' => "\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00", # [27]
223 'syntax' => "\x00\x00\x00\x00\x00\x00\x00\x55\x55\x15\x00\x00", # [28..38]
224 'taint' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00", # [39]
225 'threads' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00", # [40]
226 'uninitialized' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00", # [41]
227 'unopened' => "\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [11]
228 'unpack' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00", # [42]
229 'untie' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00", # [43]
230 'utf8' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", # [44]
231 'void' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04", # [45]
232 'y2k' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", # [46]
236 'all' => "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\x2a", # [0..46]
237 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00", # [29]
238 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00", # [30]
239 'closed' => "\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6]
240 'closure' => "\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1]
241 'debugging' => "\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00", # [22]
242 'deprecated' => "\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [2]
243 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00", # [31]
244 'exec' => "\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7]
245 'exiting' => "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3]
246 'glob' => "\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4]
247 'inplace' => "\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00", # [23]
248 'internal' => "\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00", # [24]
249 'io' => "\x00\xa8\xaa\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [5..11]
250 'layer' => "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8]
251 'malloc' => "\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00", # [25]
252 'misc' => "\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00", # [12]
253 'newline' => "\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9]
254 'numeric' => "\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00", # [13]
255 'once' => "\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00", # [14]
256 'overflow' => "\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00", # [15]
257 'pack' => "\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00", # [16]
258 'parenthesis' => "\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00", # [32]
259 'pipe' => "\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [10]
260 'portable' => "\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00", # [17]
261 'precedence' => "\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00", # [33]
262 'printf' => "\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00", # [34]
263 'prototype' => "\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00", # [35]
264 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00", # [36]
265 'recursion' => "\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00", # [18]
266 'redefine' => "\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00", # [19]
267 'regexp' => "\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00", # [20]
268 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00", # [37]
269 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00", # [38]
270 'severe' => "\x00\x00\x00\x00\x00\xa8\x0a\x00\x00\x00\x00\x00", # [21..25]
271 'signal' => "\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00", # [26]
272 'substr' => "\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00", # [27]
273 'syntax' => "\x00\x00\x00\x00\x00\x00\x00\xaa\xaa\x2a\x00\x00", # [28..38]
274 'taint' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00", # [39]
275 'threads' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00", # [40]
276 'uninitialized' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00", # [41]
277 'unopened' => "\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [11]
278 'unpack' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00", # [42]
279 'untie' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00", # [43]
280 'utf8' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02", # [44]
281 'void' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08", # [45]
282 'y2k' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", # [46]
285 $NONE = "\0\0\0\0\0\0\0\0\0\0\0\0";
289 $All = "" ; vec($All, $Offsets{'all'}, 2) = 3 ;
293 delete $Carp::CarpInternal{'warnings'};
299 # called from B::Deparse.pm
301 push @_, 'all' unless @_;
308 foreach my $word ( @_ ) {
309 if ($word eq 'FATAL') {
313 elsif ($word eq 'NONFATAL') {
317 elsif ($catmask = $Bits{$word}) {
319 $mask |= $DeadBits{$word} if $fatal ;
320 $mask &= ~($DeadBits{$word}|$All) if $no_fatal ;
323 { Croaker("Unknown warnings category '$word'")}
337 my $mask = ${^WARNING_BITS} ;
339 if (vec($mask, $Offsets{'all'}, 1)) {
340 $mask |= $Bits{'all'} ;
341 $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1);
344 push @_, 'all' unless @_;
346 foreach my $word ( @_ ) {
347 if ($word eq 'FATAL') {
351 elsif ($word eq 'NONFATAL') {
355 elsif ($catmask = $Bits{$word}) {
357 $mask |= $DeadBits{$word} if $fatal ;
358 $mask &= ~($DeadBits{$word}|$All) if $no_fatal ;
361 { Croaker("Unknown warnings category '$word'")}
364 ${^WARNING_BITS} = $mask ;
372 my $mask = ${^WARNING_BITS} ;
374 if (vec($mask, $Offsets{'all'}, 1)) {
375 $mask |= $Bits{'all'} ;
376 $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1);
379 push @_, 'all' unless @_;
381 foreach my $word ( @_ ) {
382 if ($word eq 'FATAL') {
385 elsif ($catmask = $Bits{$word}) {
386 $mask &= ~($catmask | $DeadBits{$word} | $All);
389 { Croaker("Unknown warnings category '$word'")}
392 ${^WARNING_BITS} = $mask ;
402 # check the category supplied.
405 Croaker ("not an object")
406 if $category !~ /^([^=]+)=/ ;
410 $offset = $Offsets{$category};
411 Croaker("Unknown warnings category '$category'")
412 unless defined $offset;
415 $category = (caller(1))[0] ;
416 $offset = $Offsets{$category};
417 Croaker("package '$category' not registered for warnings")
418 unless defined $offset ;
421 my $this_pkg = (caller(1))[0] ;
426 while (do { { package DB; $pkg = (caller($i++))[0] } } ) {
427 last unless @DB::args && $DB::args[0] =~ /^$category=/ ;
432 for ($i = 2 ; $pkg = (caller($i))[0] ; ++ $i) {
433 last if $pkg ne $this_pkg ;
436 if !$pkg || $pkg eq $this_pkg ;
439 my $callers_bitmask = (caller($i))[9] ;
440 return ($callers_bitmask, $offset, $i) ;
445 Croaker("Usage: warnings::enabled([category])")
446 unless @_ == 1 || @_ == 0 ;
448 my ($callers_bitmask, $offset, $i) = __chk(@_) ;
450 return 0 unless defined $callers_bitmask ;
451 return vec($callers_bitmask, $offset, 1) ||
452 vec($callers_bitmask, $Offsets{'all'}, 1) ;
458 Croaker("Usage: warnings::warn([category,] 'message')")
459 unless @_ == 2 || @_ == 1 ;
462 my ($callers_bitmask, $offset, $i) = __chk(@_) ;
464 if vec($callers_bitmask, $offset+1, 1) ||
465 vec($callers_bitmask, $Offsets{'all'}+1, 1) ;
471 Croaker("Usage: warnings::warnif([category,] 'message')")
472 unless @_ == 2 || @_ == 1 ;
475 my ($callers_bitmask, $offset, $i) = __chk(@_) ;
478 unless defined $callers_bitmask &&
479 (vec($callers_bitmask, $offset, 1) ||
480 vec($callers_bitmask, $Offsets{'all'}, 1)) ;
483 if vec($callers_bitmask, $offset+1, 1) ||
484 vec($callers_bitmask, $Offsets{'all'}+1, 1) ;