[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
C<our $foo;> generates spurious warning
Here's a fix for this:
% perl5.00563 -we 'our $x; $x = 1; print $x;'
Useless use of a variable in void context at -e line 1.
1
Sarathy
gsar@ActiveState.com
-----------------------------------8<-----------------------------------
Change 4800 by gsar@auger on 2000/01/14 01:27:13
avoid spurious "Useless use of variable" warning on C<our $foo;>
Affected files ...
... //depot/perl/dump.c#55 edit
... //depot/perl/op.c#234 edit
... //depot/perl/op.h#45 edit
Differences ...
==== //depot/perl/dump.c#55 (text) ====
Index: perl/dump.c
--- perl/dump.c.~1~ Thu Jan 13 17:27:18 2000
+++ perl/dump.c Thu Jan 13 17:27:18 2000
@@ -485,6 +485,8 @@
else {
if (o->op_private & HINT_STRICT_REFS)
sv_catpv(tmpsv, ",STRICT_REFS");
+ if (o->op_private & OPpOUR_INTRO)
+ sv_catpv(tmpsv, ",OUR_INTRO");
}
}
else if (o->op_type == OP_CONST) {
==== //depot/perl/op.c#234 (text) ====
Index: perl/op.c
--- perl/op.c.~1~ Thu Jan 13 17:27:18 2000
+++ perl/op.c Thu Jan 13 17:27:18 2000
@@ -1074,7 +1074,7 @@
case OP_RV2SV:
case OP_RV2AV:
case OP_RV2HV:
- if (!(o->op_private & OPpLVAL_INTRO) &&
+ if (!(o->op_private & (OPpLVAL_INTRO|OPpOUR_INTRO)) &&
(!o->op_sibling || o->op_sibling->op_type != OP_READLINE))
useless = "a variable";
break;
@@ -1830,6 +1830,7 @@
} else if (type == OP_RV2SV || /* "our" declaration */
type == OP_RV2AV ||
type == OP_RV2HV) { /* XXX does this let anything illegal in? */
+ o->op_private |= OPpOUR_INTRO;
return o;
} else if (type != OP_PADSV &&
type != OP_PADAV &&
==== //depot/perl/op.h#45 (text) ====
Index: perl/op.h
--- perl/op.h.~1~ Thu Jan 13 17:27:18 2000
+++ perl/op.h Thu Jan 13 17:27:18 2000
@@ -136,7 +136,9 @@
#define OPpEARLY_CV 32 /* foo() called before sub foo was parsed */
/* OP_?ELEM only */
#define OPpLVAL_DEFER 16 /* Defer creation of array/hash elem */
- /* for OP_RV2?V, lower bits carry hints */
+ /* OP_RV2?V only */
+#define OPpOUR_INTRO 16 /* Defer creation of array/hash elem */
+ /* for OP_RV2?V, lower bits carry hints (currently only HINT_STRICT_REFS) */
/* Private for OPs with TARGLEX */
/* (lower bits may carry MAXARG) */
End of Patch.
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]