comparison gen/toir.cpp @ 467:261b05cf4d1c

Fixed problem in AssignExp where the result value might be uninitialized. see mini/assign1.d
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 03 Aug 2008 16:59:28 +0200
parents e381e082d5cb
children 45a67b6f1310
comparison
equal deleted inserted replaced
466:6989f040ea06 467:261b05cf4d1c
446 446
447 ////////////////////////////////////////////////////////////////////////////////////////// 447 //////////////////////////////////////////////////////////////////////////////////////////
448 448
449 DValue* AssignExp::toElem(IRState* p) 449 DValue* AssignExp::toElem(IRState* p)
450 { 450 {
451 Logger::print("AssignExp::toElem: %s | %s = %s\n", toChars(), e1->type->toChars(), e2->type ? e2->type->toChars() : 0); 451 Logger::print("AssignExp::toElem: %s | (%s)(%s = %s)\n", toChars(), type->toChars(), e1->type->toChars(), e2->type ? e2->type->toChars() : 0);
452 LOG_SCOPE; 452 LOG_SCOPE;
453 453
454 if (e1->op == TOKarraylength) 454 if (e1->op == TOKarraylength)
455 { 455 {
456 Logger::println("performing array.length assignment"); 456 Logger::println("performing array.length assignment");
470 DtoAssign(loc, l, r); 470 DtoAssign(loc, l, r);
471 471
472 if (l->isSlice() || l->isComplex()) 472 if (l->isSlice() || l->isComplex())
473 return l; 473 return l;
474 474
475 LLValue* v; 475 if (type->toBasetype()->ty == Tstruct && e2->type->isintegral())
476 if (l->isVar() && l->isVar()->lval) 476 {
477 v = l->getLVal(); 477 // handle struct = 0;
478 return l;
479 }
478 else 480 else
479 v = l->getRVal(); 481 {
480 482 assert(type->equals(e2->type));
481 return new DVarValue(type, v, true); 483 return r;
484 }
482 } 485 }
483 486
484 ////////////////////////////////////////////////////////////////////////////////////////// 487 //////////////////////////////////////////////////////////////////////////////////////////
485 488
486 DValue* AddExp::toElem(IRState* p) 489 DValue* AddExp::toElem(IRState* p)