mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-27 09:03:15 +01:00
Make invalid compile time casts an error instead of asserting.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user