Mercurial > projects > ldc
comparison dmd/optimize.c @ 888:d8c44f1e08e1
Fix #164.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 17 Jan 2009 17:41:03 +0100 |
parents | 330f999ade44 |
children | e74e2e53ba3b |
comparison
equal
deleted
inserted
replaced
887:7f6eeb7b003e | 888:d8c44f1e08e1 |
---|---|
350 if ((e1->op == TOKstring || e1->op == TOKarrayliteral) && | 350 if ((e1->op == TOKstring || e1->op == TOKarrayliteral) && |
351 (type->ty == Tpointer || type->ty == Tarray) && | 351 (type->ty == Tpointer || type->ty == Tarray) && |
352 type->next->equals(e1->type->next) | 352 type->next->equals(e1->type->next) |
353 ) | 353 ) |
354 { | 354 { |
355 // make a copy before adjusting type to avoid | |
356 // messing up the type of an existing initializer | |
357 e1 = e1->syntaxCopy(); | |
355 e1->type = type; | 358 e1->type = type; |
356 return e1; | 359 return e1; |
357 } | 360 } |
358 /* The first test here is to prevent infinite loops | 361 /* The first test here is to prevent infinite loops |
359 */ | 362 */ |
360 if (op1 != TOKarrayliteral && e1->op == TOKarrayliteral) | 363 if (op1 != TOKarrayliteral && e1->op == TOKarrayliteral) |
361 return e1->castTo(NULL, to); | 364 return e1->castTo(NULL, to); |
362 if (e1->op == TOKnull && | 365 if (e1->op == TOKnull && |
363 (type->ty == Tpointer || type->ty == Tclass)) | 366 (type->ty == Tpointer || type->ty == Tclass)) |
364 { | 367 { |
368 e1 = e1->syntaxCopy(); | |
365 e1->type = type; | 369 e1->type = type; |
366 return e1; | 370 return e1; |
367 } | 371 } |
368 | 372 |
369 if (result & WANTflags && type->ty == Tclass && e1->type->ty == Tclass) | 373 if (result & WANTflags && type->ty == Tclass && e1->type->ty == Tclass) |
375 | 379 |
376 cdfrom = e1->type->isClassHandle(); | 380 cdfrom = e1->type->isClassHandle(); |
377 cdto = type->isClassHandle(); | 381 cdto = type->isClassHandle(); |
378 if (cdto->isBaseOf(cdfrom, &offset) && offset == 0) | 382 if (cdto->isBaseOf(cdfrom, &offset) && offset == 0) |
379 { | 383 { |
384 e1 = e1->syntaxCopy(); | |
380 e1->type = type; | 385 e1->type = type; |
381 return e1; | 386 return e1; |
382 } | 387 } |
383 } | 388 } |
384 | 389 |
389 if (e1->op == TOKsymoff) | 394 if (e1->op == TOKsymoff) |
390 { | 395 { |
391 if (type->size() == e1->type->size() && | 396 if (type->size() == e1->type->size() && |
392 type->toBasetype()->ty != Tsarray) | 397 type->toBasetype()->ty != Tsarray) |
393 { | 398 { |
399 e1 = e1->syntaxCopy(); | |
394 e1->type = type; | 400 e1->type = type; |
395 return e1; | 401 return e1; |
396 } | 402 } |
397 return this; | 403 return this; |
398 } | 404 } |