sv_setpvn(sv, WARN_NONEstring, WARNsize) ;
}
else if (PL_compiling.cop_warnings == pWARN_ALL) {
- sv_setpvn(sv, WARN_ALLstring, WARNsize) ;
+ /* Get the bit mask for $warnings::Bits{all}, because
+ * it could have been extended by warnings::register */
+ SV **bits_all;
+ HV *bits=get_hv("warnings::Bits", FALSE);
+ if (bits && (bits_all=hv_fetch(bits, "all", 3, FALSE))) {
+ sv_setsv(sv, *bits_all);
+ }
+ else {
+ sv_setpvn(sv, WARN_ALLstring, WARNsize) ;
+ }
}
else {
sv_setsv(sv, PL_compiling.cop_warnings);
(old_warnings == pWARN_STD && (PL_dowarn & G_WARN_ON) == 0))
mask = newSVpvn(WARN_NONEstring, WARNsize) ;
else if (old_warnings == pWARN_ALL ||
- (old_warnings == pWARN_STD && PL_dowarn & G_WARN_ON))
- mask = newSVpvn(WARN_ALLstring, WARNsize) ;
+ (old_warnings == pWARN_STD && PL_dowarn & G_WARN_ON)) {
+ /* Get the bit mask for $warnings::Bits{all}, because
+ * it could have been extended by warnings::register */
+ SV **bits_all;
+ HV *bits = get_hv("warnings::Bits", FALSE);
+ if (bits && (bits_all=hv_fetch(bits, "all", 3, FALSE))) {
+ mask = newSVsv(*bits_all);
+ }
+ else {
+ mask = newSVpvn(WARN_ALLstring, WARNsize) ;
+ }
+ }
else
mask = newSVsv(old_warnings);
PUSHs(sv_2mortal(mask));
chdir 't' if -d 't';
@INC = '../lib';
require './test.pl';
+ plan( tests => 27 );
}
-plan( tests => 20 );
-
my @c;
print "# Tests with caller(0)\n";
$fooref2 -> ();
is( $c[3], "(unknown)", "unknown subroutine name" );
ok( $c[4], "hasargs true with unknown sub" );
+
+# See if caller() returns the correct warning mask
+
+sub testwarn {
+ my $w = shift;
+ is( (caller(0))[9], $w, "warnings");
+}
+
+# NB : extend the warning mask values below when new warnings are added
+{
+ no warnings;
+ BEGIN { is( ${^WARNING_BITS}, "\0" x 12, 'warning bits' ) }
+ testwarn("\0" x 12);
+ use warnings;
+ BEGIN { is( ${^WARNING_BITS}, "U" x 12, 'warning bits' ) }
+ BEGIN { testwarn("U" x 12); }
+ # run-time :
+ # the warning mask has been extended by warnings::register
+ testwarn("UUUUUUUUUUUU\001");
+ use warnings::register;
+ BEGIN { is( ${^WARNING_BITS}, "UUUUUUUUUUUU\001", 'warning bits' ) }
+ testwarn("UUUUUUUUUUUU\001");
+}