Make sure the program doesn't have a dereference of a non-pointer type.

This commit is contained in:
Matt Pharr
2012-02-06 14:19:27 -08:00
parent a2b5ce0172
commit ee91fa1228
2 changed files with 16 additions and 1 deletions

View File

@@ -6305,8 +6305,17 @@ DereferenceExpr::GetType() const {
Expr *
DereferenceExpr::TypeCheck() {
if (expr == NULL)
if (expr == NULL) {
Assert(m->errorCount > 0);
return NULL;
}
if (dynamic_cast<const PointerType *>(expr->GetType()) == NULL) {
Error(pos, "Illegal to dereference non-pointer type \"%s\".",
expr->GetType()->GetString().c_str());
return NULL;
}
return this;
}