Backing out r55607 due to logic errors and test regression.

I'll try to come up with a correct fix for the testcase sometime soon.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55614 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index d93a5ec..7e60da5 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1076,13 +1076,6 @@
     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;
@@ -1105,8 +1098,6 @@
       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:
@@ -1169,7 +1160,12 @@
   case Expr::ImplicitCastExprClass:
   case Expr::ExplicitCastExprClass: {
     const Expr *SubExpr = cast<CastExpr>(Init)->getSubExpr();
-    return CheckArithmeticConstantExpression(SubExpr);
+    if (SubExpr->getType()->isArithmeticType())
+      return CheckArithmeticConstantExpression(SubExpr);
+
+    Diag(Init->getExprLoc(),
+         diag::err_init_element_not_constant, Init->getSourceRange());
+    return true;
   }
   case Expr::ConditionalOperatorClass: {
     const ConditionalOperator *Exp = cast<ConditionalOperator>(Init);