mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-12 02:43:14 +01:00
Fixed unlisted contract parameter issue.
Thanks to alexrp for mentioning it.
This commit is contained in:
31
dmd2/func.c
31
dmd2/func.c
@@ -146,19 +146,26 @@ Dsymbol *FuncDeclaration::syntaxCopy(Dsymbol *s)
|
||||
}
|
||||
|
||||
#if IN_LLVM
|
||||
static int outToRefDg(void *ctx, size_t n, Parameter *p, int flags)
|
||||
{
|
||||
if (p->storageClass & STCout)
|
||||
{
|
||||
// Cannot just use syntaxCopy() here, because it would cause the
|
||||
// parameter type to be semantic()ed again, in the wrong scope. So,
|
||||
// just copy the outer layer to modify the storage class.
|
||||
void *cpy = malloc(sizeof(Parameter));
|
||||
memcpy(cpy, (void *)p, sizeof(Parameter));
|
||||
p = (Parameter *)cpy;
|
||||
p->storageClass &= ~STCout;
|
||||
p->storageClass |= STCref;
|
||||
}
|
||||
((Parameters *)ctx)->push(p);
|
||||
return 0;
|
||||
}
|
||||
static Parameters *outToRef(Parameters* params)
|
||||
{
|
||||
Parameters *result = Parameter::arraySyntaxCopy(params);
|
||||
size_t dim = Parameter::dim(result);
|
||||
for (size_t i = 0; i < dim; i++)
|
||||
{
|
||||
Parameter *p = Parameter::getNth(result, i);
|
||||
if (p->storageClass & STCout)
|
||||
{
|
||||
p->storageClass &= ~STCout;
|
||||
p->storageClass |= STCref;
|
||||
}
|
||||
}
|
||||
Parameters *result = new Parameters();
|
||||
Parameter::foreach(params, &outToRefDg, result);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
@@ -811,7 +818,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||
*/
|
||||
fdrequireParams = new Expressions();
|
||||
Parameters *params = outToRef(((TypeFunction*)type)->parameters);
|
||||
TypeFunction *tf = new TypeFunction(params, Type::tvoid, 0, LINKd);
|
||||
Type *tf = new TypeFunction(params, Type::tvoid, 0, LINKd);
|
||||
#else
|
||||
/* in { ... }
|
||||
* becomes:
|
||||
|
||||
Submodule tests/d2/dmd-testsuite updated: a4a9f28605...acbafb4804
Reference in New Issue
Block a user