d: Return the correct value for C++ constructor calls (PR101664)
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 26 Jul 2021 17:34:33 +0000 (19:34 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Thu, 29 Jul 2021 15:10:09 +0000 (17:10 +0200)
commit7616ed6307c90b5bbf1bf53550d33cc674ab4b6f
tree54b64dfacbd3bd53468ab91c176a033cb390383a
parent5c9b7408dc578cb2ae142a5c1b724c183497bdb2
d: Return the correct value for C++ constructor calls (PR101664)

C++ constructors return void, even though the front-end semantic treats
them as implicitly returning `this'.  To handle this correctly, the
object reference is cached and used as the result of the expression.

PR d/101664

gcc/d/ChangeLog:

* expr.cc (ExprVisitor::visit (CallExp *)): Use object expression as
result for C++ constructor calls.

gcc/testsuite/ChangeLog:

* gdc.dg/extern-c++/extern-c++.exp: New.
* gdc.dg/extern-c++/pr101664.d: New test.
* gdc.dg/extern-c++/pr101664_1.cc: New test.
gcc/d/expr.cc
gcc/testsuite/gdc.dg/extern-c++/extern-c++.exp [new file with mode: 0644]
gcc/testsuite/gdc.dg/extern-c++/pr101664.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/extern-c++/pr101664_1.cc [new file with mode: 0644]