Changeset 789
- Timestamp:
- 12/06/10 20:21:32 (14 years ago)
- Files:
-
- trunk/src/expression.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/expression.c
r787 r789 8588 8588 // Do compile time array bounds checking if possible 8589 8589 e2 = e2->optimize(WANTvalue); 8590 8590 if (e2->op == TOKint64) 8591 8591 { 8592 8592 dinteger_t index = e2->toInteger(); 8593 8593 dinteger_t length = tsa->dim->toInteger(); 8594 8594 if (index < 0 || index >= length) 8595 8595 error("array index [%lld] is outside array bounds [0 .. %lld]", 8596 8596 index, length); 8597 8597 } 8598 8598 #endif 8599 8599 e->type = t1->nextOf(); 8600 8600 break; 8601 8601 } 8602 8602 8603 8603 case Taarray: 8604 8604 { TypeAArray *taa = (TypeAArray *)t1; 8605 8605 /* We can skip the implicit conversion if they differ only by 8606 8606 * constness (Bugzilla 2684, see also bug 2954b) 8607 8607 */ 8608 if (!arrayTypeCompatible (e2->loc, e2->type, taa->index))8608 if (!arrayTypeCompatibleWithoutCasting(e2->loc, e2->type, taa->index)) 8609 8609 { 8610 8610 e2 = e2->implicitCastTo(sc, taa->index); // type checking 8611 8611 } 8612 8612 type = taa->next; 8613 8613 break; 8614 8614 } 8615 8615 8616 8616 case Ttuple: 8617 8617 { 8618 8618 e2 = e2->implicitCastTo(sc, Type::tsize_t); 8619 8619 e2 = e2->optimize(WANTvalue | WANTinterpret); 8620 8620 uinteger_t index = e2->toUInteger(); 8621 8621 size_t length; 8622 8622 TupleExp *te; 8623 8623 TypeTuple *tup; 8624 8624 8625 8625 if (e1->op == TOKtuple) 8626 8626 { te = (TupleExp *)e1; 8627 8627 length = te->exps->dim; 8628 8628 }
