Mercurial > projects > ldc
comparison gen/toir.cpp @ 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 | 6b62e8cdf970 |
children | 8d98e42ece93 |
comparison
equal
deleted
inserted
replaced
312:553f844ae5b9 | 313:a498b736a0bd |
---|---|
70 } | 70 } |
71 // normal stack variable | 71 // normal stack variable |
72 else { | 72 else { |
73 // allocate storage on the stack | 73 // allocate storage on the stack |
74 const LLType* lltype = DtoType(vd->type); | 74 const LLType* lltype = DtoType(vd->type); |
75 if(gTargetData->getTypeSizeInBits(lltype) == 0) | |
76 { | |
77 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()); | |
78 fatal(); | |
79 } | |
75 llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint()); | 80 llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint()); |
76 //allocainst->setAlignment(vd->type->alignsize()); // TODO | 81 //allocainst->setAlignment(vd->type->alignsize()); // TODO |
77 assert(!vd->ir.irLocal); | 82 assert(!vd->ir.irLocal); |
78 vd->ir.irLocal = new IrLocal(vd); | 83 vd->ir.irLocal = new IrLocal(vd); |
79 vd->ir.irLocal->value = allocainst; | 84 vd->ir.irLocal->value = allocainst; |