d: Fix no NRVO when returning an array of a non-POD struct
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 24 Aug 2020 22:39:17 +0000 (00:39 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Wed, 26 Aug 2020 08:03:55 +0000 (10:03 +0200)
commit312ad889e99ff9458c01518325775e75ab57f272
tree035ab56a65f80de27ca138bf322c70888fec1108
parent3eefc04663f325a1c76fae4d0a54284e71a57eb1
d: Fix no NRVO when returning an array of a non-POD struct

TREE_ADDRESSABLE was not propagated from the RECORD_TYPE to the ARRAY_TYPE, so
NRVO code generation was not being triggered.

gcc/d/ChangeLog:

PR d/96157
* d-codegen.cc (d_build_call): Handle TREE_ADDRESSABLE static arrays.
* types.cc (make_array_type): Propagate TREE_ADDRESSABLE from base
type to static array.

gcc/testsuite/ChangeLog:

PR d/96157
* gdc.dg/pr96157a.d: New test.
* gdc.dg/pr96157b.d: New test.
gcc/d/d-codegen.cc
gcc/d/types.cc
gcc/testsuite/gdc.dg/pr96157a.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr96157b.d [new file with mode: 0644]