Skip to content

Commit

Permalink
ParseXS: fix OUTLIST/OUTPUT override issue
Browse files Browse the repository at this point in the history
I introduced a bug during recent code refactoring. For the specific
(and unusual) case of a void XSUB with a single parameter which was
both OUTLIST and also had an OUTPUT entry with a code override:

    foo(IN_OUTLIST int A)
        OUTPUT:
            A    setA(ST[99], A);

the OUTLIST would fail to emit the code to set the new mortal to be
stored at ST(0) to the value of A.
  • Loading branch information
iabyn committed Jan 19, 2025
1 parent 9577e66 commit c6a18e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ sub as_output_code {
# original arg (via an entry in OUTPUT) and once to push the param's
# value (via OUTLIST). When doing the latter, any override code on an
# OUTPUT line should not be used.
undef $output_code if $out_num;
undef $output_code if defined $out_num;


# ------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions dist/ExtUtils-ParseXS/t/001-basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,19 @@ EOF
[ 0, 0, qr/\b\QST(1) = RETVALSV;\E\s+\}\s+\Q++SP;/, "store RETVALSV"],
[ 0, 0, qr/\b\QXSRETURN(2);/, "XSRETURN(2)" ],
],
[
"OUTLIST with OUTPUT override",
[ Q(<<'EOF') ],
|void
|foo(IN_OUTLIST int A)
| OUTPUT:
| A setA(ST[99], A);
EOF
[ 0, 1, qr/\bEXTEND\b/, "NO extend" ],
[ 0, 0, qr/\b\QsetA(ST[99], A);/, "set ST[99]" ],
[ 0, 0, qr/\b\QTARGi((IV)A, 1);/, "set ST[0]" ],
[ 0, 0, qr/\b\QXSRETURN(1);/, "XSRETURN(1)" ],
],
);

test_many($preamble, 'XS_Foo_', \@test_fns);
Expand Down

0 comments on commit c6a18e7

Please sign in to comment.