Support using pointer arithmetic as lvalue
This commit is contained in:
16
expr.cpp
16
expr.cpp
@@ -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
|
int
|
||||||
BinaryExpr::EstimateCost() const {
|
BinaryExpr::EstimateCost() const {
|
||||||
@@ -4266,8 +4277,9 @@ IndexExpr::GetValue(FunctionEmitContext *ctx) const {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Symbol *baseSym = GetBaseSymbol();
|
Symbol *baseSym = GetBaseSymbol();
|
||||||
if (dynamic_cast<FunctionCallExpr *>(baseExpr) == NULL) {
|
if (dynamic_cast<FunctionCallExpr *>(baseExpr) == NULL &&
|
||||||
// Only check for non-function calls
|
dynamic_cast<BinaryExpr *>(baseExpr) == NULL) {
|
||||||
|
// Don't check if we're doing a function call or pointer arith
|
||||||
AssertPos(pos, baseSym != NULL);
|
AssertPos(pos, baseSym != NULL);
|
||||||
}
|
}
|
||||||
mask = lMaskForSymbol(baseSym, ctx);
|
mask = lMaskForSymbol(baseSym, ctx);
|
||||||
|
|||||||
1
expr.h
1
expr.h
@@ -155,6 +155,7 @@ public:
|
|||||||
|
|
||||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||||
const Type *GetType() const;
|
const Type *GetType() const;
|
||||||
|
const Type *GetLValueType() const;
|
||||||
void Print() const;
|
void Print() const;
|
||||||
|
|
||||||
Expr *Optimize();
|
Expr *Optimize();
|
||||||
|
|||||||
Reference in New Issue
Block a user