no_bareword_allowed(o);
else {
if (ckWARN(WARN_VOID)) {
- if (SvOK(sv)) {
- SV* msv = sv_2mortal(Perl_newSVpvf(aTHX_
- "a constant (%"SVf")", sv));
- useless = SvPV_nolen(msv);
- useless_is_utf8 = SvUTF8(msv);
- }
- else
- useless = "a constant (undef)";
/* don't warn on optimised away booleans, eg
* use constant Foo, 5; Foo || print; */
if (cSVOPo->op_private & OPpCONST_SHORTCIRCUIT)
strnEQ(maybe_macro, "ds", 2) ||
strnEQ(maybe_macro, "ig", 2))
useless = NULL;
+ else {
+ SV * const dsv = newSV(0);
+ SV* msv = sv_2mortal(Perl_newSVpvf(aTHX_
+ "a constant (%s)",
+ pv_pretty(dsv, maybe_macro, SvCUR(sv), 32, NULL, NULL,
+ PERL_PV_PRETTY_DUMP | PERL_PV_ESCAPE_NOCLEAR | PERL_PV_ESCAPE_UNI_DETECT )));
+ SvREFCNT_dec(dsv);
+ useless = SvPV_nolen(msv);
+ useless_is_utf8 = SvUTF8(msv);
+ }
}
+ else if (SvOK(sv)) {
+ SV* msv = sv_2mortal(Perl_newSVpvf(aTHX_
+ "a constant (%"SVf")", sv));
+ useless = SvPV_nolen(msv);
+ }
+ else
+ useless = "a constant (undef)";
}
}
op_null(o); /* don't execute or even remember it */
2 + 2; # optimized to OP_CONST
use constant U => undef;
U;
+qq/" \n/;
5 || print "bad\n"; # test OPpCONST_SHORTCIRCUIT
print "boo\n" if U; # test OPpCONST_SHORTCIRCUIT
no warnings 'void' ;
"x" . "y"; # optimized to OP_CONST
2 + 2; # optimized to OP_CONST
EXPECT
-Useless use of a constant (abc) in void context at - line 3.
+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 ("xy") in void context at - line 5.
Useless use of a constant (4) in void context at - line 6.
Useless use of a constant (undef) in void context at - line 8.
+Useless use of a constant ("\"\t\n") in void context at - line 9.
########
# op.c
use utf8;
"àḆc"; # OP_CONST
"Ẋ" . "ƴ"; # optimized to OP_CONST
EXPECT
-Useless use of a constant (àḆc) in void context at - line 5.
-Useless use of a constant (Ẋƴ) in void context at - line 6.
-Useless use of a constant (FOO) in void context at - line 7.
+Useless use of a constant ("\340\x{1e06}c") in void context at - line 5.
+Useless use of a constant ("\x{1e8a}\x{1b4}") in void context at - line 6.
+Useless use of a constant ("\x{ff26}\x{ff2f}\x{ff2f}") in void context at - line 7.
Useless use of a constant (undef) in void context at - line 9.
########
# op.c
Use of qw(...) as parentheses is deprecated at - line 2.
Use of qw(...) as parentheses is deprecated at - line 3.
Use of qw(...) as parentheses is deprecated at - line 4.
-Useless use of a constant (z) in void context at - line 4.
+Useless use of a constant ("z") in void context at - line 4.
Use of qw(...) as parentheses is deprecated at - line 5.
-Useless use of a constant (z) in void context at - line 5.
+Useless use of a constant ("z") in void context at - line 5.
x0
x2
########
Use of qw(...) as parentheses is deprecated at - line 2.
Use of qw(...) as parentheses is deprecated at - line 3.
Use of qw(...) as parentheses is deprecated at - line 4.
-Useless use of a constant (z) in void context at - line 4.
+Useless use of a constant ("z") in void context at - line 4.
Use of qw(...) as parentheses is deprecated at - line 5.
-Useless use of a constant (z) in void context at - line 5.
+Useless use of a constant ("z") in void context at - line 5.
x1
x3
########
Use of qw(...) as parentheses is deprecated at - line 2.
Use of qw(...) as parentheses is deprecated at - line 3.
Use of qw(...) as parentheses is deprecated at - line 4.
-Useless use of a constant (z) in void context at - line 4.
+Useless use of a constant ("z") in void context at - line 4.
Use of qw(...) as parentheses is deprecated at - line 5.
-Useless use of a constant (z) in void context at - line 5.
+Useless use of a constant ("z") in void context at - line 5.
x0
x2
########
EXPECT
Use of qw(...) as parentheses is deprecated at - line 2.
Use of qw(...) as parentheses is deprecated at - line 3.
-Useless use of a constant (z) in void context at - line 3.
+Useless use of a constant ("z") in void context at - line 3.
x0 a
x1 a
########
Use of qw(...) as parentheses is deprecated at - line 2.
Use of qw(...) as parentheses is deprecated at - line 3.
Use of qw(...) as parentheses is deprecated at - line 4.
-Useless use of a constant (z) in void context at - line 4.
+Useless use of a constant ("z") in void context at - line 4.
Use of qw(...) as parentheses is deprecated at - line 5.
-Useless use of a constant (z) in void context at - line 5.
+Useless use of a constant ("z") in void context at - line 5.
x0
x2
########
Use of qw(...) as parentheses is deprecated at - line 2.
Use of qw(...) as parentheses is deprecated at - line 3.
Use of qw(...) as parentheses is deprecated at - line 4.
-Useless use of a constant (z) in void context at - line 4.
+Useless use of a constant ("z") in void context at - line 4.
Use of qw(...) as parentheses is deprecated at - line 5.
-Useless use of a constant (z) in void context at - line 5.
+Useless use of a constant ("z") in void context at - line 5.
x0
x2
########
Use of qw(...) as parentheses is deprecated at - line 2.
Use of qw(...) as parentheses is deprecated at - line 3.
Use of qw(...) as parentheses is deprecated at - line 4.
-Useless use of a constant (z) in void context at - line 4.
+Useless use of a constant ("z") in void context at - line 4.
Use of qw(...) as parentheses is deprecated at - line 5.
-Useless use of a constant (z) in void context at - line 5.
+Useless use of a constant ("z") in void context at - line 5.
x1
x3
########