use warnings;
use strict;
-use Test::More tests => 3;
+use Test::More tests => 4;
use XS::APItest 'lv_temp_object';
lv_temp_object() = 75;
like $w, qr/Useless assignment to a temporary at/,
'warning when assigning to temp returned from XS lv sub';
+ undef $w;
+ (lv_temp_object()) = 75;
+ like $w, qr/Useless assignment to a temporary at/,
+ 'warning when list-assigning to temp returned from XS lv sub';
$w = undef;
{
break;
}
if (relem <= lastrelem) {
+ if (
+ SvTEMP(sv) && !SvSMAGICAL(sv) && SvREFCNT(sv) == 1 &&
+ (!isGV_with_GP(sv) || SvFAKE(sv)) && ckWARN(WARN_MISC)
+ )
+ Perl_warner(aTHX_
+ packWARN(WARN_MISC),
+ "Useless assignment to a temporary"
+ );
sv_setsv(sv, *relem);
*(relem++) = sv;
}