Make sure the program doesn't have a dereference of a non-pointer type.
This commit is contained in:
11
expr.cpp
11
expr.cpp
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user