summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2017-12-06 04:00:04 +0000
committerZefram <zefram@fysh.org>2017-12-06 04:00:04 +0000
commit52e3acf87aacbe6b39ecb42fe0adb6c0dac1019d (patch)
treed789ce56ac7364b4acb33c4c492a715efc55eb0c
parent58be57636a42d6c6fd404c48c4e1cb87870182df (diff)
downloadperl-52e3acf87aacbe6b39ecb42fe0adb6c0dac1019d.tar.gz
put shadowing warnings in their own category
As proposed in [perl #125330].
-rw-r--r--ext/XS-APItest/t/loopblock.t2
-rw-r--r--ext/XS-APItest/t/looprest.t2
-rw-r--r--lib/warnings.pm11
-rw-r--r--pad.c8
-rw-r--r--pod/perldelta.pod6
-rw-r--r--pod/perldiag.pod8
-rw-r--r--regen/warnings.pl3
-rw-r--r--t/lib/warnings/pad42
-rw-r--r--warnings.h4
9 files changed, 52 insertions, 34 deletions
diff --git a/ext/XS-APItest/t/loopblock.t b/ext/XS-APItest/t/loopblock.t
index 3b688bc811..7f654a5424 100644
--- a/ext/XS-APItest/t/loopblock.t
+++ b/ext/XS-APItest/t/loopblock.t
@@ -70,7 +70,7 @@ eval q{
my $x = "a";
$t .= $x;
do {
- no warnings "misc";
+ no warnings "shadow";
$t .= $x;
my $x = "b";
$t .= $x;
diff --git a/ext/XS-APItest/t/looprest.t b/ext/XS-APItest/t/looprest.t
index e37ef87941..aa3116daa8 100644
--- a/ext/XS-APItest/t/looprest.t
+++ b/ext/XS-APItest/t/looprest.t
@@ -66,7 +66,7 @@ eval q{
my $x = "a";
$t .= $x;
do {
- no warnings "misc";
+ no warnings "shadow";
$t .= $x;
my $x = "b";
$t .= $x;
diff --git a/lib/warnings.pm b/lib/warnings.pm
index 64e6448a08..c6bbe8c95d 100644
--- a/lib/warnings.pm
+++ b/lib/warnings.pm
@@ -5,7 +5,7 @@
package warnings;
-our $VERSION = "1.38";
+our $VERSION = "1.39";
# Verify that we're called correctly so that warnings will work.
# Can't use Carp, since Carp uses us!
@@ -96,6 +96,9 @@ our %Offsets = (
# Warnings Categories added in Perl 5.025
'experimental::declared_refs' => 132,
+
+ # Warnings Categories added in Perl 5.027
+ 'shadow' => 134,
);
our %Bits = (
@@ -153,6 +156,7 @@ our %Bits = (
'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00", # [37]
'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00", # [38]
'severe' => "\x00\x00\x00\x00\x00\x54\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [21..25]
+ 'shadow' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40", # [67]
'signal' => "\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [26]
'substr' => "\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [27]
'surrogate' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00", # [50]
@@ -223,6 +227,7 @@ our %DeadBits = (
'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00", # [37]
'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00", # [38]
'severe' => "\x00\x00\x00\x00\x00\xa8\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [21..25]
+ 'shadow' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80", # [67]
'signal' => "\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [26]
'substr' => "\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [27]
'surrogate' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00", # [50]
@@ -241,7 +246,7 @@ our %DeadBits = (
# These are used by various things, including our own tests
our $NONE = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
our $DEFAULT = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x00\x55\x51\x55\x10", # [2,4,22,23,25,52..56,58..63,66]
-our $LAST_BIT = 134 ;
+our $LAST_BIT = 136 ;
our $BYTES = 17 ;
sub Croaker
@@ -811,6 +816,8 @@ The current hierarchy is:
| |
| +- malloc
|
+ +- shadow
+ |
+- signal
|
+- substr
diff --git a/pad.c b/pad.c
index 9c20d66e94..d1311e2e0b 100644
--- a/pad.c
+++ b/pad.c
@@ -857,7 +857,7 @@ S_pad_check_dup(pTHX_ PADNAME *name, U32 flags, const HV *ourstash)
assert((flags & ~padadd_OUR) == 0);
- if (PadnamelistMAX(PL_comppad_name) < 0 || !ckWARN(WARN_MISC))
+ if (PadnamelistMAX(PL_comppad_name) < 0 || !ckWARN(WARN_SHADOW))
return; /* nothing to check */
svp = PadnamelistARRAY(PL_comppad_name);
@@ -875,7 +875,7 @@ S_pad_check_dup(pTHX_ PADNAME *name, U32 flags, const HV *ourstash)
if (is_our && (SvPAD_OUR(sv)))
break; /* "our" masking "our" */
/* diag_listed_as: "%s" variable %s masks earlier declaration in same %s */
- Perl_warner(aTHX_ packWARN(WARN_MISC),
+ Perl_warner(aTHX_ packWARN(WARN_SHADOW),
"\"%s\" %s %" PNf " masks earlier declaration in same %s",
( is_our ? "our" :
PL_parser->in_my == KEY_my ? "my" :
@@ -901,10 +901,10 @@ S_pad_check_dup(pTHX_ PADNAME *name, U32 flags, const HV *ourstash)
&& SvOURSTASH(sv) == ourstash
&& memEQ(PadnamePV(sv), PadnamePV(name), PadnameLEN(name)))
{
- Perl_warner(aTHX_ packWARN(WARN_MISC),
+ Perl_warner(aTHX_ packWARN(WARN_SHADOW),
"\"our\" variable %" PNf " redeclared", PNfARG(sv));
if (off <= PL_comppad_name_floor)
- Perl_warner(aTHX_ packWARN(WARN_MISC),
+ Perl_warner(aTHX_ packWARN(WARN_SHADOW),
"\t(Did you mean \"local\" instead of \"our\"?)\n");
break;
}
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index c4c85746b7..9e8b4360ed 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -236,6 +236,12 @@ XXX Changes (i.e. rewording) of diagnostic messages go here
XXX Describe change here
+=item *
+
+Warnings that a variable or subroutine "masks earlier declaration in same
+...", or that an C<our> variable has been redeclared, have been moved to a
+new warnings category "shadow". Previously they were in category "misc".
+
=back
=head1 Utility Changes
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 528fd40339..c38fc0f032 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -2047,7 +2047,7 @@ some such.
=item (Did you mean "local" instead of "our"?)
-(W misc) Remember that "our" does not localize the declared global
+(W shadow) Remember that "our" does not localize the declared global
variable. You have declared it again in the same lexical scope, which
seems superfluous.
@@ -4402,7 +4402,7 @@ have a specific default. You probably want "$a = undef".
=item "our" variable %s redeclared
-(W misc) You seem to have already declared the same global once before
+(W shadow) You seem to have already declared the same global once before
in the current lexical scope.
=item Out of memory!
@@ -5797,7 +5797,7 @@ being executed, so its &a is not available for capture.
=item "%s" subroutine &%s masks earlier declaration in same %s
-(W misc) A "my" or "state" subroutine has been redeclared in the
+(W shadow) A "my" or "state" subroutine has been redeclared in the
current scope or statement, effectively eliminating all access to
the previous instance. This is almost always a typographical error.
Note that the earlier subroutine will still exist until the end of
@@ -7326,7 +7326,7 @@ See L<re>.
=item "%s" variable %s masks earlier declaration in same %s
-(W misc) A "my", "our" or "state" variable has been redeclared in the
+(W shadow) A "my", "our" or "state" variable has been redeclared in the
current scope or statement, effectively eliminating all access to the
previous instance. This is almost always a typographical error. Note
that the earlier variable will still exist until the end of the scope
diff --git a/regen/warnings.pl b/regen/warnings.pl
index b9692ab5ea..b090d4b862 100644
--- a/regen/warnings.pl
+++ b/regen/warnings.pl
@@ -16,7 +16,7 @@
#
# This script is normally invoked from regen.pl.
-$VERSION = '1.38';
+$VERSION = '1.39';
BEGIN {
require './regen/regen_lib.pl';
@@ -112,6 +112,7 @@ my $tree = {
'missing' => [ 5.021, DEFAULT_OFF],
'redundant' => [ 5.021, DEFAULT_OFF],
'locale' => [ 5.021, DEFAULT_ON],
+ 'shadow' => [ 5.027, DEFAULT_OFF],
#'default' => [ 5.008, DEFAULT_ON ],
}]};
diff --git a/t/lib/warnings/pad b/t/lib/warnings/pad
index 4e31fe338b..bd8e9c0675 100644
--- a/t/lib/warnings/pad
+++ b/t/lib/warnings/pad
@@ -29,7 +29,7 @@
__END__
# pad.c
-use warnings 'misc' ;
+use warnings 'shadow' ;
my $x ;
my $x ;
my $y = my $y ;
@@ -37,7 +37,7 @@ my $p ;
package X ;
my $p ;
package main ;
-no warnings 'misc' ;
+no warnings 'shadow' ;
my $x ;
my $y ;
my $p ;
@@ -47,7 +47,7 @@ EXPECT
"my" variable $p masks earlier declaration in same scope at - line 8.
########
# pad.c
-use warnings 'misc' ;
+use warnings 'shadow' ;
our $x ;
my $x ;
our $y = my $y ;
@@ -55,7 +55,7 @@ our $p ;
package X ;
my $p ;
package main ;
-no warnings 'misc' ;
+no warnings 'shadow' ;
our $z ;
my $z ;
our $t = my $t ;
@@ -68,7 +68,7 @@ EXPECT
"my" variable $p masks earlier declaration in same scope at - line 8.
########
# pad.c
-use warnings 'misc' ;
+use warnings 'shadow' ;
my $x ;
our $x ;
my $y = our $y ;
@@ -76,7 +76,7 @@ my $p ;
package X ;
our $p ;
package main ;
-no warnings 'misc' ;
+no warnings 'shadow' ;
my $z ;
our $z ;
my $t = our $t ;
@@ -234,7 +234,7 @@ our $y;
sub { $x = $y }->(); # should not warn about $y being unavailable
EXPECT
########
-use warnings 'misc' ;
+use warnings 'shadow' ;
my $x;
{
my $x;
@@ -242,7 +242,7 @@ my $x;
EXPECT
########
# pad.c
-use warnings 'misc' ;
+use warnings 'shadow' ;
our $x ;
our $x ;
our $y = our $y ;
@@ -250,7 +250,7 @@ our $p ;
package X ;
our $p ;
package main ;
-no warnings 'misc' ;
+no warnings 'shadow' ;
our $a ;
our $a ;
our $b = our $b ;
@@ -261,13 +261,13 @@ EXPECT
"our" variable $x redeclared at - line 4.
"our" variable $y redeclared at - line 5.
########
-use warnings 'misc' ;
+use warnings 'shadow' ;
our $x;
{
our $x;
}
our $x;
-no warnings 'misc' ;
+no warnings 'shadow' ;
our $y;
{
our $y;
@@ -278,36 +278,36 @@ EXPECT
(Did you mean "local" instead of "our"?)
"our" variable $x redeclared at - line 6.
########
-use warnings 'misc' ;
+use warnings 'shadow' ;
our $x;
{
my $x;
}
-no warnings 'misc' ;
+no warnings 'shadow' ;
our $y;
{
my $y;
}
EXPECT
########
-use warnings 'misc' ;
+use warnings 'shadow' ;
my $x;
{
our $x;
}
-no warnings 'misc' ;
+no warnings 'shadow' ;
my $y;
{
our $y;
}
EXPECT
########
-use warnings 'misc' ;
+use warnings 'shadow' ;
my $x;
{
my $x;
}
-no warnings 'misc' ;
+no warnings 'shadow' ;
my $y;
{
my $y;
@@ -320,13 +320,13 @@ use warnings;
our $x unless $x;
EXPECT
########
-use warnings 'misc';
+use warnings 'shadow';
our $qunckkk;
our $_;
package clank_est;
our $qunckkk;
our $_;
-no warnings 'misc';
+no warnings 'shadow';
our $ouch;
our $_;
package whack;
@@ -335,7 +335,7 @@ our $_;
EXPECT
"our" variable $_ redeclared at - line 6.
########
-use warnings 'misc';
+use warnings 'shadow';
BEGIN { binmode STDERR, 'utf8'; }
{
use utf8;
@@ -345,7 +345,7 @@ BEGIN { binmode STDERR, 'utf8'; }
EXPECT
"my" variable $ニコニコ masks earlier declaration in same scope at - line 6.
########
-use warnings 'misc';
+use warnings 'shadow';
BEGIN { binmode STDERR, 'utf8'; }
{
use utf8;
diff --git a/warnings.h b/warnings.h
index c2831a2938..9ea5c8fb32 100644
--- a/warnings.h
+++ b/warnings.h
@@ -115,6 +115,10 @@
#define WARN_EXPERIMENTAL__DECLARED_REFS 66
+/* Warnings Categories added in Perl 5.027 */
+
+#define WARN_SHADOW 67
+
#define WARNsize 17
#define WARN_ALLstring "\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125"
#define WARN_NONEstring "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"