diff options
-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 |