Support using pointer arithmetic as lvalue

This commit is contained in:
james.brodman
2013-10-30 17:07:26 -04:00
parent 61c33969a2
commit 9ce6fbe1fa
2 changed files with 15 additions and 2 deletions

View File

@@ -2798,6 +2798,17 @@ BinaryExpr::TypeCheck() {
}
}
const Type *
BinaryExpr::GetLValueType() const {
const Type *t = GetType();
if (CastType<PointerType>(t) != NULL) {
// Are we doing something like (basePtr + offset)[...] = ...
return t;
}
else {
return NULL;
}
}
int
BinaryExpr::EstimateCost() const {
@@ -4266,8 +4277,9 @@ IndexExpr::GetValue(FunctionEmitContext *ctx) const {
}
else {
Symbol *baseSym = GetBaseSymbol();
if (dynamic_cast<FunctionCallExpr *>(baseExpr) == NULL) {
// Only check for non-function calls
if (dynamic_cast<FunctionCallExpr *>(baseExpr) == NULL &&
dynamic_cast<BinaryExpr *>(baseExpr) == NULL) {
// Don't check if we're doing a function call or pointer arith
AssertPos(pos, baseSym != NULL);
}
mask = lMaskForSymbol(baseSym, ctx);