[Diagnostics] Fixed crash with non pointer type (PR43950)

This commit is contained in:
Dávid Bolvanský 2019-11-09 09:02:40 +01:00
parent e4da37e8a0
commit 312c6f699d
1 changed files with 2 additions and 1 deletions

View File

@ -482,7 +482,8 @@ static void CheckForNullPointerDereference(Sema &S, Expr *E) {
// to get a deterministic trap and are surprised by clang's behavior. This
// only handles the pattern "*null", which is a very syntactic check.
const auto *UO = dyn_cast<UnaryOperator>(E->IgnoreParenCasts());
if (UO && UO->getOpcode() == UO_Deref) {
if (UO && UO->getOpcode() == UO_Deref &&
UO->getSubExpr()->getType()->isPointerType()) {
const LangAS AS =
UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
if ((!isTargetAddressSpace(AS) ||