Mercurial > projects > ldc
changeset 313:a498b736a0bd trunk
[svn r334] Produce an error for zero-size types instead of segfaulting.
author | ChristianK |
---|---|
date | Sun, 29 Jun 2008 22:22:37 +0200 |
parents | 553f844ae5b9 |
children | 8d98e42ece93 |
files | gen/toir.cpp |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/toir.cpp Sun Jun 29 22:07:15 2008 +0200 +++ b/gen/toir.cpp Sun Jun 29 22:22:37 2008 +0200 @@ -72,6 +72,11 @@ else { // allocate storage on the stack const LLType* lltype = DtoType(vd->type); + if(gTargetData->getTypeSizeInBits(lltype) == 0) + { + error("Allocating a variable of type %s and size zero is not implemented. (the behaviour of alloca with zero size is undefined)", vd->type->toChars()); + fatal(); + } llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint()); //allocainst->setAlignment(vd->type->alignsize()); // TODO assert(!vd->ir.irLocal);