diff options
author | Paul Marquess <paul.marquess@btinternet.com> | 2001-10-14 12:25:08 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-10-14 13:48:30 +0000 |
commit | 08540116c788d6f1e67757a00e334989e55f0cfc (patch) | |
tree | 0c3f283bba7cebb41bd1e33b458dacccf25cc837 | |
parent | 31022a5a11db70290d5b3f56cd0dc18a4dd805d8 (diff) | |
download | perl-08540116c788d6f1e67757a00e334989e55f0cfc.tar.gz |
Fix scoping problem with FATAL warnings
Message-ID: <AIEAJICLCBDNAAOLLOKLCEFDDCAA.Paul_Marquess@Yahoo.co.uk>
p4raw-id: //depot/perl@12434
-rw-r--r-- | lib/warnings.pm | 2 | ||||
-rw-r--r-- | pod/perllexwarn.pod | 6 | ||||
-rw-r--r-- | t/lib/warnings/7fatal | 46 | ||||
-rw-r--r-- | warnings.pl | 2 |
4 files changed, 54 insertions, 2 deletions
diff --git a/lib/warnings.pm b/lib/warnings.pm index 2bf29ced5f..6b46e35729 100644 --- a/lib/warnings.pm +++ b/lib/warnings.pm @@ -314,7 +314,7 @@ sub unimport { $mask |= $Bits{'all'} ; $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); } - ${^WARNING_BITS} = $mask & ~ (bits(@_ ? @_ : 'all') | $All) ; + ${^WARNING_BITS} = $mask & ~ (bits('FATAL' => (@_ ? @_ : 'all')) | $All) ; } sub __chk diff --git a/pod/perllexwarn.pod b/pod/perllexwarn.pod index 450838737c..cd76f3af40 100644 --- a/pod/perllexwarn.pod +++ b/pod/perllexwarn.pod @@ -342,6 +342,12 @@ The scope where C<length> is used has escalated the C<void> warnings category into a fatal error, so the program terminates immediately it encounters the warning. +To explicitly disable a "FATAL" warning you just disable the warning it is +associated with. So, for example, to disable the "void" warning in the +example above, either of these will do the trick: + + no warnings qw(void); + no warnings FATAL => qw(void); =head2 Reporting Warnings from a Module diff --git a/t/lib/warnings/7fatal b/t/lib/warnings/7fatal index a25fa2c2ea..23c88d82e3 100644 --- a/t/lib/warnings/7fatal +++ b/t/lib/warnings/7fatal @@ -310,3 +310,49 @@ print "done\n" ; EXPECT Useless use of time in void context at - line 4. Useless use of length in void context at - line 8. +######## + +use warnings FATAL => 'all'; +{ + no warnings; + my $b ; chop $b; + { + use warnings ; + my $b ; chop $b; + } +} +my $b ; chop $b; +print STDERR "The End.\n" ; +EXPECT +Use of uninitialized value in scalar chop at - line 8. +Use of uninitialized value in scalar chop at - line 11. +######## + +use warnings FATAL => 'all'; +{ + no warnings FATAL => 'all'; + my $b ; chop $b; + { + use warnings ; + my $b ; chop $b; + } +} +my $b ; chop $b; +print STDERR "The End.\n" ; +EXPECT +Use of uninitialized value in scalar chop at - line 8. +Use of uninitialized value in scalar chop at - line 11. +######## + +use warnings FATAL => 'all'; +{ + no warnings 'syntax'; + { + use warnings ; + my $b ; chop $b; + } +} +my $b ; chop $b; +print STDERR "The End.\n" ; +EXPECT +Use of uninitialized value in scalar chop at - line 7. diff --git a/warnings.pl b/warnings.pl index 3dc8200169..59033486f2 100644 --- a/warnings.pl +++ b/warnings.pl @@ -491,7 +491,7 @@ sub unimport { $mask |= $Bits{'all'} ; $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); } - ${^WARNING_BITS} = $mask & ~ (bits(@_ ? @_ : 'all') | $All) ; + ${^WARNING_BITS} = $mask & ~ (bits('FATAL' => (@_ ? @_ : 'all')) | $All) ; } sub __chk |