comparison dmd/optimize.c @ 893:e74e2e53ba3b

Remove optimizer syntax copies where they weren't proven to be necessary. Copying without calling semantic() leads to issues for more complicated expressions.
author Christian Kamm <kamm incasoftware de>
date Sun, 18 Jan 2009 14:14:40 +0100
parents d8c44f1e08e1
children c519caae3181
comparison
equal deleted inserted replaced
892:063ba84a965f 893:e74e2e53ba3b
363 if (op1 != TOKarrayliteral && e1->op == TOKarrayliteral) 363 if (op1 != TOKarrayliteral && e1->op == TOKarrayliteral)
364 return e1->castTo(NULL, to); 364 return e1->castTo(NULL, to);
365 if (e1->op == TOKnull && 365 if (e1->op == TOKnull &&
366 (type->ty == Tpointer || type->ty == Tclass)) 366 (type->ty == Tpointer || type->ty == Tclass))
367 { 367 {
368 e1 = e1->syntaxCopy();
369 e1->type = type; 368 e1->type = type;
370 return e1; 369 return e1;
371 } 370 }
372 371
373 if (result & WANTflags && type->ty == Tclass && e1->type->ty == Tclass) 372 if (result & WANTflags && type->ty == Tclass && e1->type->ty == Tclass)
379 378
380 cdfrom = e1->type->isClassHandle(); 379 cdfrom = e1->type->isClassHandle();
381 cdto = type->isClassHandle(); 380 cdto = type->isClassHandle();
382 if (cdto->isBaseOf(cdfrom, &offset) && offset == 0) 381 if (cdto->isBaseOf(cdfrom, &offset) && offset == 0)
383 { 382 {
384 e1 = e1->syntaxCopy();
385 e1->type = type; 383 e1->type = type;
386 return e1; 384 return e1;
387 } 385 }
388 } 386 }
389 387
394 if (e1->op == TOKsymoff) 392 if (e1->op == TOKsymoff)
395 { 393 {
396 if (type->size() == e1->type->size() && 394 if (type->size() == e1->type->size() &&
397 type->toBasetype()->ty != Tsarray) 395 type->toBasetype()->ty != Tsarray)
398 { 396 {
399 e1 = e1->syntaxCopy();
400 e1->type = type; 397 e1->type = type;
401 return e1; 398 return e1;
402 } 399 }
403 return this; 400 return this;
404 } 401 }