getPrimaryDecl can return null.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46638 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 67c967f..278c07f 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -1634,7 +1634,7 @@
     // &X[4] and &4[X] is invalid if X is invalid and X is not a pointer.
   
     ValueDecl *VD = getPrimaryDecl(cast<ArraySubscriptExpr>(e)->getBase());
-    if (VD->getType()->isPointerType())
+    if (!VD || VD->getType()->isPointerType())
       return 0;
     else
       return VD;