make CheckArithmeticConstantExpression() aware of &foo and pointers

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55607 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 599f0ba..bf7c690 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1076,6 +1076,13 @@
     const Decl *D = cast<DeclRefExpr>(Init)->getDecl();
     if (isa<EnumConstantDecl>(D))
       return false;
+
+    if (const ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
+      QualType Ty = VD->getType();
+      if (Ty->isPointerLikeType() || Ty->isArrayType())
+        return false;
+    }
+
     Diag(Init->getExprLoc(),
          diag::err_init_element_not_constant, Init->getSourceRange());
     return true;
@@ -1098,6 +1105,8 @@
       Diag(Init->getExprLoc(),
            diag::err_init_element_not_constant, Init->getSourceRange());
       return true;
+    case UnaryOperator::AddrOf:
+      return false;
     case UnaryOperator::SizeOf:
     case UnaryOperator::AlignOf:
     case UnaryOperator::OffsetOf:
@@ -1160,12 +1169,7 @@
   case Expr::ImplicitCastExprClass:
   case Expr::ExplicitCastExprClass: {
     const Expr *SubExpr = cast<CastExpr>(Init)->getSubExpr();
-    if (SubExpr->getType()->isArithmeticType())
-      return CheckArithmeticConstantExpression(SubExpr);
-
-    Diag(Init->getExprLoc(),
-         diag::err_init_element_not_constant, Init->getSourceRange());
-    return true;
+    return CheckArithmeticConstantExpression(SubExpr);
   }
   case Expr::ConditionalOperatorClass: {
     const ConditionalOperator *Exp = cast<ConditionalOperator>(Init);