Fix over-aggressive check in DereferenceExpr::TypeCheck()

(Reference types are allowed as well.)
This commit is contained in:
Matt Pharr
2012-02-07 08:18:33 -08:00
parent 6b3e14b0a4
commit 33ea934c8f

View File

@@ -6325,9 +6325,10 @@ DereferenceExpr::TypeCheck() {
return NULL;
}
if (dynamic_cast<const PointerType *>(expr->GetType()) == NULL) {
Error(pos, "Illegal to dereference non-pointer type \"%s\".",
expr->GetType()->GetString().c_str());
if (dynamic_cast<const PointerType *>(expr->GetType()) == NULL &&
dynamic_cast<const ReferenceType *>(expr->GetType()) == NULL) {
Error(pos, "Illegal to dereference non-pointer or reference "
"type \"%s\".", expr->GetType()->GetString().c_str());
return NULL;
}