mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 19:36:06 +03:00
Properly handle DMD-internal "reference variables".
Previously, we just had a hack to make ref foreach statements work. This commit enables them to work in other cases as well, like the implicit __result variable for functions with out-contracts (which is such a magic ref variable for ref-returning functions). Fixes DMD testcase 'testcontracts'.
This commit is contained in:
parent
6b1b84a28d
commit
ee4285f934
8 changed files with 173 additions and 172 deletions
|
@ -98,6 +98,7 @@ void DtoResolveDsymbol(Dsymbol* dsym);
|
|||
void DtoConstInitGlobal(VarDeclaration* vd);
|
||||
|
||||
// declaration inside a declarationexp
|
||||
void DtoVarDeclaration(VarDeclaration* var);
|
||||
DValue* DtoDeclarationExp(Dsymbol* declaration);
|
||||
LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr = 0);
|
||||
|
||||
|
@ -158,6 +159,14 @@ LLValue* makeLValue(Loc& loc, DValue* value);
|
|||
void callPostblit(Loc &loc, Expression *exp, LLValue *val);
|
||||
#endif
|
||||
|
||||
/// Returns whether the given variable is a DMD-internal "ref variable".
|
||||
///
|
||||
/// D doesn't have reference variables (the ref keyword is only usable in
|
||||
/// function signatures and foreach headers), but the DMD frontend internally
|
||||
/// creates them in cases like lowering a ref foreach to a for loop or the
|
||||
/// implicit __result variable for ref-return functions with out contracts.
|
||||
bool isSpecialRefVar(VarDeclaration* vd);
|
||||
|
||||
////////////////////////////////////////////
|
||||
// gen/tocall.cpp stuff below
|
||||
////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue