Changeset 379
- Timestamp:
- 02/12/10 06:55:03 (15 years ago)
- Files:
-
- branches/dmd-1.x/src/expression.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/expression.c
r370 r379 7333 7333 // Rewrite as to.call(e1) 7334 7334 e = new TypeExp(loc, to); 7335 7335 e = new DotIdExp(loc, e, Id::call); 7336 7336 e = new CallExp(loc, e, e1); 7337 7337 e = e->semantic(sc); 7338 7338 return e; 7339 7339 } 7340 7340 7341 7341 // Struct casts are possible only when the sizes match 7342 7342 if (tob->ty == Tstruct || t1b->ty == Tstruct) 7343 7343 { 7344 7344 size_t fromsize = t1b->size(loc); 7345 7345 size_t tosize = tob->size(loc); 7346 7346 if (fromsize != tosize) 7347 7347 { 7348 7348 error("cannot cast from %s to %s", e1->type->toChars(), to->toChars()); 7349 7349 return new ErrorExp(); 7350 7350 } 7351 7351 } 7352 7352 } 7353 7354 if (!e1->type) 7355 { error("cannot cast %s", e1->toChars()); 7356 return new ErrorExp(); 7357 } 7358 7353 7359 e = e1->castTo(sc, to); 7354 7360 return e; 7355 7361 } 7356 7362 7357 7363 int CastExp::checkSideEffect(int flag) 7358 7364 { 7359 7365 /* if not: 7360 7366 * cast(void) 7361 7367 * cast(classtype)func() 7362 7368 */ 7363 7369 if (!to->equals(Type::tvoid) && 7364 7370 !(to->ty == Tclass && e1->op == TOKcall && e1->type->ty == Tclass)) 7365 7371 return Expression::checkSideEffect(flag); 7366 7372 return 1; 7367 7373 } 7368 7374 7369 7375 void CastExp::checkEscape() 7370 7376 { Type *tb = type->toBasetype(); 7371 7377 if (tb->ty == Tarray && e1->op == TOKvar && 7372 7378 e1->type->toBasetype()->ty == Tsarray)
