Add missing cases to watch out for in lCheckAllOffSafety()

Previously, we weren't checking for member expressions that dereferenced
a pointer or pointer dereference expressions--only array indexing!
This commit is contained in:
Matt Pharr
2012-01-11 09:09:40 -08:00
parent 0223bb85ee
commit 9670ab0887
2 changed files with 17 additions and 1 deletions

1
expr.h
View File

@@ -314,7 +314,6 @@ public:
std::string identifier;
const SourcePos identifierPos;
protected:
MemberExpr(Expr *expr, const char *identifier, SourcePos pos,
SourcePos identifierPos, bool derefLValue);

View File

@@ -695,6 +695,23 @@ lCheckAllOffSafety(ASTNode *node, void *data) {
}
// All indices are in-bounds
return true;
}
MemberExpr *me;
if ((me = dynamic_cast<MemberExpr *>(node)) != NULL &&
me->dereferenceExpr) {
*okPtr = false;
return false;
}
DereferenceExpr *de;
if ((de = dynamic_cast<DereferenceExpr *>(node)) != NULL) {
const Type *exprType = de->expr->GetType();
if (dynamic_cast<const PointerType *>(exprType) != NULL) {
*okPtr = false;
return false;
}
}
return true;