Skip to content

Commit 60282a4

Browse files
author
Karl Williamson
committed
PATCH: [perl #114178] di/ds/ig exempt from warnings in void context
1 parent 2e0b8fb commit 60282a4

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

op.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,29 +1394,16 @@ Perl_scalarvoid(pTHX_ OP *o)
13941394
else if (SvNIOK(sv) && (SvNV(sv) == 0.0 || SvNV(sv) == 1.0))
13951395
useless = NULL;
13961396
else if (SvPOK(sv)) {
1397-
/* perl4's way of mixing documentation and code
1398-
(before the invention of POD) was based on a
1399-
trick to mix nroff and perl code. The trick was
1400-
built upon these three nroff macros being used in
1401-
void context. The pink camel has the details in
1402-
the script wrapman near page 319. */
1403-
const char * const maybe_macro = SvPVX_const(sv);
1404-
if (strnEQ(maybe_macro, "di", 2) ||
1405-
strnEQ(maybe_macro, "ds", 2) ||
1406-
strnEQ(maybe_macro, "ig", 2))
1407-
useless = NULL;
1408-
else {
14091397
SV * const dsv = newSVpvs("");
14101398
useless_sv
14111399
= Perl_newSVpvf(aTHX_
14121400
"a constant (%s)",
1413-
pv_pretty(dsv, maybe_macro,
1401+
pv_pretty(dsv, SvPVX_const(sv),
14141402
SvCUR(sv), 32, NULL, NULL,
14151403
PERL_PV_PRETTY_DUMP
14161404
| PERL_PV_ESCAPE_NOCLEAR
14171405
| PERL_PV_ESCAPE_UNI_DETECT));
14181406
SvREFCNT_dec_NN(dsv);
1419-
}
14201407
}
14211408
else if (SvOK(sv)) {
14221409
useless_sv = Perl_newSVpvf(aTHX_ "a constant (%"SVf")", sv);

t/lib/warnings/op

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ eval { getpwuid 1 }; # OP_GPWUID
225225
prototype "foo"; # OP_PROTOTYPE
226226
$a ~~ $b; # OP_SMARTMATCH
227227
$a <=> $b; # OP_NCMP
228+
"dsatrewq";
229+
"diatrewq";
230+
"igatrewq";
228231
use 5.015;
229232
__SUB__ # OP_RUNCV
230233
EXPECT
@@ -269,7 +272,10 @@ Useless use of getpwuid in void context at - line 53.
269272
Useless use of subroutine prototype in void context at - line 54.
270273
Useless use of smart match in void context at - line 55.
271274
Useless use of numeric comparison (<=>) in void context at - line 56.
272-
Useless use of __SUB__ in void context at - line 58.
275+
Useless use of a constant ("dsatrewq") in void context at - line 57.
276+
Useless use of a constant ("diatrewq") in void context at - line 58.
277+
Useless use of a constant ("igatrewq") in void context at - line 59.
278+
Useless use of __SUB__ in void context at - line 61.
273279
########
274280
# op.c
275281
use warnings 'void' ; close STDIN ;

0 commit comments

Comments
 (0)