r282857 - Fix int <= bool comparison warning on MSVC

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 30 07:18:06 PDT 2016


Author: rksimon
Date: Fri Sep 30 09:18:06 2016
New Revision: 282857

URL: http://llvm.org/viewvc/llvm-project?rev=282857&view=rev
Log:
Fix int <= bool comparison warning on MSVC

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=282857&r1=282856&r2=282857&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Sep 30 09:18:06 2016
@@ -2366,11 +2366,14 @@ void Sema::DeclareGlobalNewDelete() {
     bool HasSizedVariant = getLangOpts().SizedDeallocation &&
                            (Kind == OO_Delete || Kind == OO_Array_Delete);
     bool HasAlignedVariant = getLangOpts().CPlusPlus1z;
-    for (int Sized = 0; Sized <= HasSizedVariant; ++Sized) {
+
+    int NumSizeVariants = (HasSizedVariant ? 2 : 1);
+    int NumAlignVariants = (HasAlignedVariant ? 2 : 1);
+    for (int Sized = 0; Sized < NumSizeVariants; ++Sized) {
       if (Sized)
         Params.push_back(SizeT);
 
-      for (int Aligned = 0; Aligned <= HasAlignedVariant; ++Aligned) {
+      for (int Aligned = 0; Aligned < NumAlignVariants; ++Aligned) {
         if (Aligned)
           Params.push_back(Context.getTypeDeclType(getStdAlignValT()));
 




More information about the cfe-commits mailing list