Mercurial > projects > ldc
comparison gen/statements.cpp @ 399:0e6b4d65d3f8
Give error messages for invalid casts.
This required passing Loc information to certain functions.
Fixes nocompile/b/bug_cgcs_354_A/B.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 26 Jul 2008 17:19:16 +0200 |
parents | 71a40b62b408 |
children | 672eb4893b55 |
comparison
equal
deleted
inserted
replaced
398:811f82dfddbd | 399:0e6b4d65d3f8 |
---|---|
65 DValue* rvar = new DVarValue(f->type->next, f->decl->ir.irFunc->retArg, true); | 65 DValue* rvar = new DVarValue(f->type->next, f->decl->ir.irFunc->retArg, true); |
66 | 66 |
67 DValue* e = exp->toElem(p); | 67 DValue* e = exp->toElem(p); |
68 | 68 |
69 if (!e->inPlace()) | 69 if (!e->inPlace()) |
70 DtoAssign(rvar, e); | 70 DtoAssign(loc, rvar, e); |
71 | 71 |
72 DtoEnclosingHandlers(enclosinghandler, NULL); | 72 DtoEnclosingHandlers(enclosinghandler, NULL); |
73 | 73 |
74 if (global.params.symdebug) DtoDwarfFuncEnd(f->decl); | 74 if (global.params.symdebug) DtoDwarfFuncEnd(f->decl); |
75 llvm::ReturnInst::Create(p->scopebb()); | 75 llvm::ReturnInst::Create(p->scopebb()); |
158 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endif", gIR->topfunc(), oldend); | 158 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endif", gIR->topfunc(), oldend); |
159 llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb; | 159 llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb; |
160 | 160 |
161 if (cond_val->getType() != LLType::Int1Ty) { | 161 if (cond_val->getType() != LLType::Int1Ty) { |
162 Logger::cout() << "if conditional: " << *cond_val << '\n'; | 162 Logger::cout() << "if conditional: " << *cond_val << '\n'; |
163 cond_val = DtoBoolean(cond_e); | 163 cond_val = DtoBoolean(loc, cond_e); |
164 } | 164 } |
165 LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb()); | 165 LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb()); |
166 | 166 |
167 // replace current scope | 167 // replace current scope |
168 gIR->scope() = IRScope(ifbb,elsebb); | 168 gIR->scope() = IRScope(ifbb,elsebb); |
246 // replace current scope | 246 // replace current scope |
247 gIR->scope() = IRScope(whilebb,endbb); | 247 gIR->scope() = IRScope(whilebb,endbb); |
248 | 248 |
249 // create the condition | 249 // create the condition |
250 DValue* cond_e = condition->toElem(p); | 250 DValue* cond_e = condition->toElem(p); |
251 LLValue* cond_val = DtoBoolean(cond_e); | 251 LLValue* cond_val = DtoBoolean(loc, cond_e); |
252 delete cond_e; | 252 delete cond_e; |
253 | 253 |
254 // conditional branch | 254 // conditional branch |
255 LLValue* ifbreak = llvm::BranchInst::Create(whilebodybb, endbb, cond_val, p->scopebb()); | 255 LLValue* ifbreak = llvm::BranchInst::Create(whilebodybb, endbb, cond_val, p->scopebb()); |
256 | 256 |
297 body->toIR(p); | 297 body->toIR(p); |
298 p->loopbbs.pop_back(); | 298 p->loopbbs.pop_back(); |
299 | 299 |
300 // create the condition | 300 // create the condition |
301 DValue* cond_e = condition->toElem(p); | 301 DValue* cond_e = condition->toElem(p); |
302 LLValue* cond_val = DtoBoolean(cond_e); | 302 LLValue* cond_val = DtoBoolean(loc, cond_e); |
303 delete cond_e; | 303 delete cond_e; |
304 | 304 |
305 // conditional branch | 305 // conditional branch |
306 LLValue* ifbreak = llvm::BranchInst::Create(dowhilebb, endbb, cond_val, gIR->scopebb()); | 306 LLValue* ifbreak = llvm::BranchInst::Create(dowhilebb, endbb, cond_val, gIR->scopebb()); |
307 | 307 |
339 // replace current scope | 339 // replace current scope |
340 gIR->scope() = IRScope(forbb,forbodybb); | 340 gIR->scope() = IRScope(forbb,forbodybb); |
341 | 341 |
342 // create the condition | 342 // create the condition |
343 DValue* cond_e = condition->toElem(p); | 343 DValue* cond_e = condition->toElem(p); |
344 LLValue* cond_val = DtoBoolean(cond_e); | 344 LLValue* cond_val = DtoBoolean(loc, cond_e); |
345 delete cond_e; | 345 delete cond_e; |
346 | 346 |
347 // conditional branch | 347 // conditional branch |
348 assert(!gIR->scopereturned()); | 348 assert(!gIR->scopereturned()); |
349 llvm::BranchInst::Create(forbodybb, endbb, cond_val, gIR->scopebb()); | 349 llvm::BranchInst::Create(forbodybb, endbb, cond_val, gIR->scopebb()); |
675 if (DSliceValue* sval = val->isSlice()) | 675 if (DSliceValue* sval = val->isSlice()) |
676 { | 676 { |
677 // give storage | 677 // give storage |
678 llval = new llvm::AllocaInst(DtoType(e->type), "tmp", gIR->topallocapoint()); | 678 llval = new llvm::AllocaInst(DtoType(e->type), "tmp", gIR->topallocapoint()); |
679 DVarValue* vv = new DVarValue(e->type, llval, true); | 679 DVarValue* vv = new DVarValue(e->type, llval, true); |
680 DtoAssign(vv, val); | 680 DtoAssign(e->loc, vv, val); |
681 } | 681 } |
682 else | 682 else |
683 { | 683 { |
684 llval = val->getRVal(); | 684 llval = val->getRVal(); |
685 } | 685 } |
992 value->ir.irLocal->value = DtoGEP1(val,loadedKey); | 992 value->ir.irLocal->value = DtoGEP1(val,loadedKey); |
993 | 993 |
994 if (!value->isRef() && !value->isOut()) { | 994 if (!value->isRef() && !value->isOut()) { |
995 DValue* dst = new DVarValue(value->type, valvar, true); | 995 DValue* dst = new DVarValue(value->type, valvar, true); |
996 DValue* src = new DVarValue(value->type, value->ir.irLocal->value, true); | 996 DValue* src = new DVarValue(value->type, value->ir.irLocal->value, true); |
997 DtoAssign(dst, src); | 997 DtoAssign(loc, dst, src); |
998 value->ir.irLocal->value = valvar; | 998 value->ir.irLocal->value = valvar; |
999 } | 999 } |
1000 | 1000 |
1001 // emit body | 1001 // emit body |
1002 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,nextbb,endbb)); | 1002 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,nextbb,endbb)); |