[cfe-commits] r86174 - in /cfe/trunk: lib/AST/ASTContext.cpp test/Sema/const-eval.c

Sebastian Redl sebastian.redl at getdesigned.at
Thu Nov 5 13:10:57 PST 2009


Author: cornedbee
Date: Thu Nov  5 15:10:57 2009
New Revision: 86174

URL: http://llvm.org/viewvc/llvm-project?rev=86174&view=rev
Log:
Make ASTContext::getIntWidth return 1 for all boolean type variations, not just for the unqualified, unaliased bool.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/Sema/const-eval.c

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

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Nov  5 15:10:57 2009
@@ -4394,7 +4394,7 @@
 //===----------------------------------------------------------------------===//
 
 unsigned ASTContext::getIntWidth(QualType T) {
-  if (T == BoolTy)
+  if (T->isBooleanType())
     return 1;
   if (FixedWidthIntType *FWIT = dyn_cast<FixedWidthIntType>(T)) {
     return FWIT->getWidth();

Modified: cfe/trunk/test/Sema/const-eval.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/const-eval.c?rev=86174&r1=86173&r2=86174&view=diff

==============================================================================
--- cfe/trunk/test/Sema/const-eval.c (original)
+++ cfe/trunk/test/Sema/const-eval.c Thu Nov  5 15:10:57 2009
@@ -68,3 +68,8 @@
 EVAL_EXPR(33, (void*)0 - (void*)0 == 0 ? 1 : -1)
 void foo(void) {}
 EVAL_EXPR(34, (foo == (void *)0) ? -1 : 1)
+
+// No PR. Mismatched bitwidths lead to a crash on second evaluation.
+const _Bool constbool = 0;
+EVAL_EXPR(35, constbool)
+EVAL_EXPR(36, constbool)





More information about the cfe-commits mailing list