]> granicus.if.org Git - clang/commitdiff
Make ASTContext::getIntWidth return 1 for all boolean type variations, not just for...
authorSebastian Redl <sebastian.redl@getdesigned.at>
Thu, 5 Nov 2009 21:10:57 +0000 (21:10 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Thu, 5 Nov 2009 21:10:57 +0000 (21:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86174 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/Sema/const-eval.c

index 8562249479ca4a8c27fa703cb38c61491ef90837..a6b0dfbaf49f568a29c8588755e7b3f88aca7180 100644 (file)
@@ -4394,7 +4394,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
 //===----------------------------------------------------------------------===//
 
 unsigned ASTContext::getIntWidth(QualType T) {
-  if (T == BoolTy)
+  if (T->isBooleanType())
     return 1;
   if (FixedWidthIntType *FWIT = dyn_cast<FixedWidthIntType>(T)) {
     return FWIT->getWidth();
index 72db14c82053e257e39713205941785b2fa8e2c9..87d1f155ebaf2253b6d4edd38748e129bbcbbb2e 100644 (file)
@@ -68,3 +68,8 @@ EVAL_EXPR(32, (int*)0 != (int*)0 ? -1 : 1)
 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)