[cfe-commits] r126368 - in /cfe/trunk: lib/Sema/SemaStmt.cpp test/SemaCXX/switch.cpp

Chris Lattner sabre at nondot.org
Wed Feb 23 23:31:28 PST 2011


Author: lattner
Date: Thu Feb 24 01:31:28 2011
New Revision: 126368

URL: http://llvm.org/viewvc/llvm-project?rev=126368&view=rev
Log:
compute the integer width, not the memory width here.  We want to know that
_Bool is 1 bit, not 8.  This fixes an assertion on the testcase, which is
PR9304 and rdar://9045501.

Modified:
    cfe/trunk/lib/Sema/SemaStmt.cpp
    cfe/trunk/test/SemaCXX/switch.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=126368&r1=126367&r2=126368&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Feb 24 01:31:28 2011
@@ -502,8 +502,7 @@
   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

Modified: cfe/trunk/test/SemaCXX/switch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch.cpp?rev=126368&r1=126367&r2=126368&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/switch.cpp (original)
+++ cfe/trunk/test/SemaCXX/switch.cpp Thu Feb 24 01:31:28 2011
@@ -57,3 +57,10 @@
   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: ;
+  }
+}





More information about the cfe-commits mailing list