Change 33305 by [EMAIL PROTECTED] on 2008/02/14 08:25:29

        Subject: Show constant in "Useless use of a constant in void context"
        From: Rick Delaney <[EMAIL PROTECTED]>
        Date: Wed, 13 Feb 2008 23:29:16 -0500
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/op.c#985 edit
... //depot/perl/t/lib/warnings/op#36 edit

Differences ...

==== //depot/perl/op.c#985 (text) ====
Index: perl/op.c
--- perl/op.c#984~33291~        2008-02-12 05:15:20.000000000 -0800
+++ perl/op.c   2008-02-14 00:25:29.000000000 -0800
@@ -1075,7 +1075,8 @@
            no_bareword_allowed(o);
        else {
            if (ckWARN(WARN_VOID)) {
-               useless = "a constant";
+               SV* msv = newSVpvf("a constant (%"SVf")", sv);
+               useless = SvPV_nolen(msv);
                if (o->op_private & OPpCONST_ARYBASE)
                    useless = NULL;
                /* don't warn on optimised away booleans, eg 

==== //depot/perl/t/lib/warnings/op#36 (text) ====
Index: perl/t/lib/warnings/op
--- perl/t/lib/warnings/op#35~32888~    2008-01-07 03:21:29.000000000 -0800
+++ perl/t/lib/warnings/op      2008-02-14 00:25:29.000000000 -0800
@@ -529,6 +529,8 @@
 use warnings 'void' ;
 "abc"; # OP_CONST
 7 ; # OP_CONST
+"x" . "y"; # optimized to OP_CONST
+2 + 2; # optimized to OP_CONST
 5 || print "bad\n";    # test OPpCONST_SHORTCIRCUIT
 use constant U => undef;
 print "boo\n" if U;    # test OPpCONST_SHORTCIRCUIT
@@ -536,9 +538,13 @@
 no warnings 'void' ;
 "abc"; # OP_CONST
 7 ; # OP_CONST
+"x" . "y"; # optimized to OP_CONST
+2 + 2; # optimized to OP_CONST
 EXPECT
-Useless use of a constant in void context at - line 3.
-Useless use of a constant in void context at - line 4.
+Useless use of a constant (abc) in void context at - line 3.
+Useless use of a constant (7) in void context at - line 4.
+Useless use of a constant (xy) in void context at - line 5.
+Useless use of a constant (4) in void context at - line 6.
 ########
 # op.c
 #
End of Patch.

Reply via email to