From: Paul Marquess Date: Sun, 14 Oct 2001 11:25:08 +0000 (+0100) Subject: Fix scoping problem with FATAL warnings X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=08540116c788d6f1e67757a00e334989e55f0cfc;p=p5sagit%2Fp5-mst-13.2.git Fix scoping problem with FATAL warnings Message-ID: p4raw-id: //depot/perl@12434 --- diff --git a/lib/warnings.pm b/lib/warnings.pm index 2bf29ce..6b46e35 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 4508387..cd76f3a 100644 --- a/pod/perllexwarn.pod +++ b/pod/perllexwarn.pod @@ -342,6 +342,12 @@ The scope where C is used has escalated the C 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 a25fa2c..23c88d8 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 3dc8200..5903348 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