Make invalid compile time casts an error instead of asserting.

This commit is contained in:
Christian Kamm
2008-10-01 19:15:01 +02:00
parent 04dd0ce3a7
commit 77b5e841dd

View File

@@ -829,10 +829,12 @@ LLConstant* CastExp::toConstElem(IRState* p)
LOG_SCOPE;
LLConstant* c = e1->toConstElem(p);
assert(isaPointer(c->getType()));
const LLType* lltype = DtoType(type);
assert(isaPointer(lltype));
if(!isaPointer(c->getType()) || !isaPointer(lltype)) {
error("can only cast pointers to pointers at compile time, not %s to %s", type->toChars(), e1->type->toChars());
fatal();
}
return llvm::ConstantExpr::getBitCast(c, lltype);
}