Skip to content

Commit

Permalink
Merge pull request #1754 from ibuclaw/deprecation_dg2ptr
Browse files Browse the repository at this point in the history
Deprecate casting delegates to void*
  • Loading branch information
yebblies committed Mar 16, 2013
2 parents 95ba63e + 0d9492e commit 0b14495
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -9196,6 +9196,9 @@ Expression *CastExp::semantic(Scope *sc)

if (tob->isintegral() && t1b->ty == Tarray)
deprecation("casting %s to %s is deprecated", e1->type->toChars(), to->toChars());

if (tob->ty == Tpointer && t1b->ty == Tdelegate)
deprecation("casting from %s to %s is deprecated", e1->type->toChars(), to->toChars());
}
else if (!to)
{ error("cannot cast tuple");
Expand Down
12 changes: 12 additions & 0 deletions test/fail_compilation/fail9735.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
REQUIRED_ARGS: -de
TEST_OUTPUT:
---
fail_compilation/fail9735.d(10): Deprecation: casting from void delegate() to void* is deprecated
---
*/

void* dg2ptr(void delegate() dg) {
return cast(void*) dg;
}

0 comments on commit 0b14495

Please sign in to comment.