From: Sebastian Redl Date: Thu, 5 Nov 2009 21:10:57 +0000 (+0000) Subject: Make ASTContext::getIntWidth return 1 for all boolean type variations, not just for... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=632d772a78db7e2cd9b36f8a22aee49d44486fbf;p=clang Make ASTContext::getIntWidth return 1 for all boolean type variations, not just for the unqualified, unaliased bool. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86174 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 8562249479..a6b0dfbaf4 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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(T)) { return FWIT->getWidth(); diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index 72db14c820..87d1f155eb 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -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)