mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 00:20:40 +03:00
Adapt to new special-ref result variables in out contracts
The AST now features special-ref result variables (storage classes: ref, temp, result) after rewriting out contracts; from dmd/func.d: /* out(id1) { statements1... } * out(id2) { statements2... } * ... * becomes: * out(__result) { { ref id1 = __result; { statements1... } } * { ref id2 = __result; { statements2... } } ... } */ We are talking about the `id1` and `id2` variables here. There's an existing assertion that we don't set a special-ref variable's lvalue (T**) to the sret pointer (T*) which was already triggered when compiling Phobos without unittests.
This commit is contained in:
parent
2b76e23bfe
commit
6dfaebb33e
1 changed files with 4 additions and 3 deletions
|
@ -966,9 +966,10 @@ void DtoVarDeclaration(VarDeclaration *vd) {
|
|||
|
||||
if (isIrLocalCreated(vd)) {
|
||||
// Nothing to do if it has already been allocated.
|
||||
} else if (gIR->func()->sretArg && ((gIR->func()->decl->nrvo_can &&
|
||||
gIR->func()->decl->nrvo_var == vd) ||
|
||||
vd->isResult())) {
|
||||
} else if (gIR->func()->sretArg &&
|
||||
((gIR->func()->decl->nrvo_can &&
|
||||
gIR->func()->decl->nrvo_var == vd) ||
|
||||
(vd->isResult() && !isSpecialRefVar(vd)))) {
|
||||
// Named Return Value Optimization (NRVO):
|
||||
// T f() {
|
||||
// T ret; // &ret == hidden pointer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue