Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed unlisted contract parameter issue.

Thanks to alexrp for mentioning it.
  • Loading branch information...
commit 8118c846afb7ac03665552a9bcced7d9e5693eb7 1 parent 051cd73
@klickverbot klickverbot authored
Showing with 19 additions and 12 deletions.
  1. +18 −11 dmd2/func.c
  2. +1 −1  tests/d2/dmd-testsuite
View
29 dmd2/func.c
@@ -146,19 +146,26 @@ Dsymbol *FuncDeclaration::syntaxCopy(Dsymbol *s)
}
#if IN_LLVM
-static Parameters *outToRef(Parameters* params)
+static int outToRefDg(void *ctx, size_t n, Parameter *p, int flags)
{
- Parameters *result = Parameter::arraySyntaxCopy(params);
- size_t dim = Parameter::dim(result);
- for (size_t i = 0; i < dim; i++)
+ if (p->storageClass & STCout)
{
- Parameter *p = Parameter::getNth(result, i);
- if (p->storageClass & STCout)
- {
- p->storageClass &= ~STCout;
- p->storageClass |= STCref;
- }
+ // 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 = 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:
2  tests/d2/dmd-testsuite
@@ -1 +1 @@
-Subproject commit a4a9f2860569e99dd69dea6b6ab5f5faf11cb920
+Subproject commit acbafb48042fb5b4b0de8ea1826833ef1c339d8a
Please sign in to comment.
Something went wrong with that request. Please try again.