aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/Expr.cpp11
-rw-r--r--test/SemaCXX/i-c-e-cxx.cpp6
-rw-r--r--www/cxx_status.html4
3 files changed, 19 insertions, 2 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index d686167cd0..904fe5f99c 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -865,6 +865,17 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
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: {
diff --git a/test/SemaCXX/i-c-e-cxx.cpp b/test/SemaCXX/i-c-e-cxx.cpp
new file mode 100644
index 0000000000..64ffe8bce8
--- /dev/null
+++ b/test/SemaCXX/i-c-e-cxx.cpp
@@ -0,0 +1,6 @@
+// RUN: clang -fsyntax-only -verify %s
+
+// C++-specific tests for integral constant expressions.
+
+const int c = 10;
+int ar[c];
diff --git a/www/cxx_status.html b/www/cxx_status.html
index a5a0454ab8..95ce0e5c15 100644
--- a/www/cxx_status.html
+++ b/www/cxx_status.html
@@ -1013,9 +1013,9 @@ welcome!</p>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7.1.5.1 [dcl.type.cv]</td>
<td class="complete" align="center">&#x2713;</td>
<td class="complete" align="center">&#x2713;</td>
- <td class="medium"></td>
+ <td class="complete" align="center">&#x2713;</td>
+ <td></td>
<td></td>
- <td>Const integral variables with ICE initializers are not ICEs.</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7.1.5.2 [dcl.type.simple]</td>