]> granicus.if.org Git - clang/commitdiff
compute the integer width, not the memory width here. We want to know that
authorChris Lattner <sabre@nondot.org>
Thu, 24 Feb 2011 07:31:28 +0000 (07:31 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 24 Feb 2011 07:31:28 +0000 (07:31 +0000)
_Bool is 1 bit, not 8.  This fixes an assertion on the testcase, which is
PR9304 and rdar://9045501.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126368 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaStmt.cpp
test/SemaCXX/switch.cpp

index 64827ff17797e863b7e4c328f7e234c516a49377..89957e60decaf4fd741c21525bc88294c84829bd 100644 (file)
@@ -502,8 +502,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
   bool HasDependentValue
     = CondExpr->isTypeDependent() || CondExpr->isValueDependent();
   unsigned CondWidth
-    = HasDependentValue? 0
-      : static_cast<unsigned>(Context.getTypeSize(CondTypeBeforePromotion));
+    = HasDependentValue ? 0 : Context.getIntWidth(CondTypeBeforePromotion);
   bool CondIsSigned = CondTypeBeforePromotion->isSignedIntegerType();
 
   // Accumulate all of the case values in a vector so that we can sort them
index fc13630bbf12f457b840fbc91336a6564655d8f7..3882a1f952ca7a076528f214ba4c2d483c7b4b80 100644 (file)
@@ -57,3 +57,10 @@ namespace test3 {
   template void foo<B>();
   template void foo<C>(); //expected-note {{in instantiation}}
 }
+
+// PR9304 and rdar://9045501
+void click_check_header_sizes() {
+  switch (0 == 8) {  // expected-warning {{switch condition has boolean value}}
+  case 0: ;
+  }
+}