[cfe-commits] r64015 - in /cfe/trunk: lib/AST/Expr.cpp test/SemaCXX/i-c-e-cxx.cpp www/cxx_status.html

Sebastian Redl sebastian.redl at getdesigned.at
Sat Feb 7 05:06:30 PST 2009


Author: cornedbee
Date: Sat Feb  7 07:06:23 2009
New Revision: 64015

URL: http://llvm.org/viewvc/llvm-project?rev=64015&view=rev
Log:
Make const-initialized const integral variables I-C-Es in C++.

Added:
    cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp
Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=64015&r1=64014&r2=64015&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sat Feb  7 07:06:23 2009
@@ -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: {

Added: cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp?rev=64015&view=auto

==============================================================================
--- cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp (added)
+++ cfe/trunk/test/SemaCXX/i-c-e-cxx.cpp Sat Feb  7 07:06:23 2009
@@ -0,0 +1,6 @@
+// RUN: clang -fsyntax-only -verify %s
+
+// C++-specific tests for integral constant expressions.
+
+const int c = 10;
+int ar[c];

Modified: cfe/trunk/www/cxx_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=64015&r1=64014&r2=64015&view=diff

==============================================================================
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Sat Feb  7 07:06:23 2009
@@ -1013,9 +1013,9 @@
   <td>      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>      7.1.5.2 [dcl.type.simple]</td>





More information about the cfe-commits mailing list