Skip to content

Commit

Permalink
fix Issue 6720 - ICE(cod1.c) casting return of void function to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Oct 6, 2013
1 parent fadd96c commit fbb041f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/expression.c
Expand Up @@ -10000,6 +10000,12 @@ Expression *CastExp::semantic(Scope *sc)

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

if (t1b->ty == Tvoid && tob->ty != Tvoid && e1->op != TOKfunction)
{
error("cannot cast %s of type %s to %s", e1->toChars(), e1->type->toChars(), to->toChars());
return new ErrorExp();
}
}
else if (!to)
{ error("cannot cast tuple");
Expand Down
26 changes: 26 additions & 0 deletions test/compilable/compile1.d
Expand Up @@ -417,3 +417,29 @@ static if (is(object.ModuleInfo == class))
static assert(__traits(classInstanceSize, object.ModuleInfo) !=
__traits(classInstanceSize, ModuleInfo));
}

/**************************************************
5796
**************************************************/


template A(B) {
pragma(msg, "missing ;")
enum X = 0;
}


static assert(!is(typeof(A!(int))));


/**************************************************
6720
**************************************************/
void bug6720() { }


static assert(!is(typeof(
cast(bool)bug6720()
)));


0 comments on commit fbb041f

Please sign in to comment.