Mercurial > projects > ldc
comparison gen/toir.cpp @ 624:eb444ed4a2d3
Make invalid compile time casts an error instead of asserting.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Wed, 01 Oct 2008 19:15:01 +0200 |
parents | 26fce59fe80a |
children | e3c46bcce65f |
comparison
equal
deleted
inserted
replaced
623:fe3c7af578eb | 624:eb444ed4a2d3 |
---|---|
827 { | 827 { |
828 Logger::print("CastExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | 828 Logger::print("CastExp::toConstElem: %s | %s\n", toChars(), type->toChars()); |
829 LOG_SCOPE; | 829 LOG_SCOPE; |
830 | 830 |
831 LLConstant* c = e1->toConstElem(p); | 831 LLConstant* c = e1->toConstElem(p); |
832 assert(isaPointer(c->getType())); | |
833 | |
834 const LLType* lltype = DtoType(type); | 832 const LLType* lltype = DtoType(type); |
835 assert(isaPointer(lltype)); | 833 |
834 if(!isaPointer(c->getType()) || !isaPointer(lltype)) { | |
835 error("can only cast pointers to pointers at compile time, not %s to %s", type->toChars(), e1->type->toChars()); | |
836 fatal(); | |
837 } | |
836 | 838 |
837 return llvm::ConstantExpr::getBitCast(c, lltype); | 839 return llvm::ConstantExpr::getBitCast(c, lltype); |
838 } | 840 } |
839 | 841 |
840 ////////////////////////////////////////////////////////////////////////////////////////// | 842 ////////////////////////////////////////////////////////////////////////////////////////// |