Make const-initialized const integral variables I-C-Es in C++.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64015 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index d686167..904fe5f 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -865,6 +865,17 @@
       Result = D->getInitVal();
       break;
     }
+    if (Ctx.getLangOptions().CPlusPlus &&
+        getType().getCVRQualifiers() == QualType::Const) {
+      // C++ 7.1.5.1p2
+      //   A variable of non-volatile const-qualified integral or enumeration
+      //   type initialized by an ICE can be used in ICEs.
+      if (const VarDecl *Dcl =
+              dyn_cast<VarDecl>(cast<DeclRefExpr>(this)->getDecl())) {
+        if (const Expr *Init = Dcl->getInit())
+          return Init->isIntegerConstantExpr(Result, Ctx, Loc, isEvaluated);
+      }
+    }
     if (Loc) *Loc = getLocStart();
     return false;
   case UnaryOperatorClass: {