Skip to content

Commit

Permalink
fix Issue 14283 - spurious 'this' is not an lvalue deprecation for au…
Browse files Browse the repository at this point in the history
…to ref

- suppress deprecation message for auto ref parameters as passing
  'this' to auto ref will remain correct when it becomes an rvalue
  and because it's very unlikely that the passing as ref argument
  was intentional
  • Loading branch information
MartinNowak committed Mar 15, 2015
1 parent 1361181 commit 6db86fd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/expression.c
Expand Up @@ -1617,7 +1617,14 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
}
if (p->storageClass & STCref)
{
arg = arg->toLvalue(sc, arg);
if (p->storageClass & STCauto &&
(arg->op == TOKthis || arg->op == TOKsuper))
{
// suppress deprecation message for auto ref parameter
// temporary workaround for Bugzilla 14283
}
else
arg = arg->toLvalue(sc, arg);
}
else if (p->storageClass & STCout)
{
Expand Down
23 changes: 23 additions & 0 deletions test/compilable/deprecate14283.d
@@ -0,0 +1,23 @@
// REQUIRED_ARGS: -dw

/*
TEST_OUTPUT:
---
compilable/deprecate14283.d(17): Deprecation: this is not an lvalue
compilable/deprecate14283.d(18): Deprecation: super is not an lvalue
---
*/

class C
{
void bug()
{
autoref(this); // suppress warning for auto ref
autoref(super); // suppress warning for auto ref
ref_(this); // still warns
ref_(super); // still warns
}
}

void autoref(T)(auto ref T t) {}
void ref_(T)(ref T) {}

0 comments on commit 6db86fd

Please sign in to comment.