[cfe-commits] r55255 - in /cfe/trunk: lib/AST/Expr.cpp test/SemaCXX/bool.cpp

Anders Carlsson andersca at mac.com
Sat Aug 23 14:12:35 PDT 2008


Author: andersca
Date: Sat Aug 23 16:12:35 2008
New Revision: 55255

URL: http://llvm.org/viewvc/llvm-project?rev=55255&view=rev
Log:
treat bool literals as constatnt expressions.

Added:
    cfe/trunk/test/SemaCXX/bool.cpp
Modified:
    cfe/trunk/lib/AST/Expr.cpp

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

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sat Aug 23 16:12:35 2008
@@ -720,6 +720,13 @@
     Result.setIsUnsigned(!getType()->isSignedIntegerType());
     break;
   }
+  case CXXBoolLiteralExprClass: {
+    const CXXBoolLiteralExpr *BL = cast<CXXBoolLiteralExpr>(this);
+    Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType())));
+    Result = BL->getValue();
+    Result.setIsUnsigned(!getType()->isSignedIntegerType());
+    break;
+  }
   case CXXZeroInitValueExprClass:
     Result.clear();
     break;

Added: cfe/trunk/test/SemaCXX/bool.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/bool.cpp?rev=55255&view=auto

==============================================================================
--- cfe/trunk/test/SemaCXX/bool.cpp (added)
+++ cfe/trunk/test/SemaCXX/bool.cpp Sat Aug 23 16:12:35 2008
@@ -0,0 +1,7 @@
+// RUN: clang -fsyntax-only -verify %s 
+
+// Bool literals can be enum values.
+enum {
+  ReadWrite = false,
+  ReadOnly = true
+};





More information about the cfe-commits mailing list