aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2009-11-05 21:10:57 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2009-11-05 21:10:57 +0000
commit632d772a78db7e2cd9b36f8a22aee49d44486fbf (patch)
tree881b578b4a3d85c7d623d06e72758b31861f7935
parent732429cfb1f77c1af61e239d0664e65962e488b3 (diff)
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
-rw-r--r--lib/AST/ASTContext.cpp2
-rw-r--r--test/Sema/const-eval.c5
2 files changed, 6 insertions, 1 deletions
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<FixedWidthIntType>(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)