Fix MSVC 2019 warnings
authorRoland Schulz <roland@rschulz.eu>
Sat, 25 Apr 2020 02:13:28 +0000 (19:13 -0700)
committerMark Abraham <mark.j.abraham@gmail.com>
Sat, 25 Apr 2020 14:56:36 +0000 (14:56 +0000)
15 files changed:
.gitignore
admin/clang-format.sh
src/gromacs/gmxana/nrama.cpp
src/gromacs/nbnxm/grid.h
src/gromacs/nbnxm/nbnxm_setup.cpp
src/gromacs/nbnxm/pairlist.h
src/gromacs/options/optionstoragetemplate.h
src/gromacs/simd/impl_x86_avx2_256/impl_x86_avx2_256_simd_float.h
src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd4_double.h
src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd4_float.h
src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_double.h
src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256_simd_float.h
src/gromacs/simd/simd.h
src/gromacs/topology/block.h
src/gromacs/utility/basedefinitions.h

index 61f53ea1c291b7e119a09334ebb35b8f0f670c72..1769456783851593d9871e1f2923d154b9d5a661 100644 (file)
@@ -26,3 +26,5 @@ _build
 CMakeLists.txt.user
 /VersionInfo*.cmake
 Testing
+/.vs
+/CMakeSettings.json
index ae8f61dfbde939d1e6441f8c0f9bdfd3d190ed4e..b2a28924dafb97c687feeca2a0e0411f55bb626d 100755 (executable)
@@ -2,7 +2,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2019, by the GROMACS development team, led by
+# Copyright (c) 2019,2020, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -98,7 +98,7 @@ then
     if [ -z "$CLANG_FORMAT" ]
     then
         echo "Please set the path to clang-format using the git hook"
-        echo "git config hooks.clang_formatpath /path/to/clang-format"
+        echo "git config hooks.clangformatpath /path/to/clang-format"
         echo "or by setting an environment variable, e.g."
         echo "CLANG_FORMAT=/path/to/clang-format"
         echo "See docs/dev-manual/code-formatting.rst for how to get clang-format."
index 1efd2f57bf181071badd162d68a6ee74d411f9cb..14b01053e1af92d517cf58cc5fbb93c0be04e4dc 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -120,7 +120,7 @@ static void add_xr(t_xrama* xr, const int ff[5], const t_atoms* atoms)
     char buf[12];
     int  i;
 
-    srenew(xr->dih, xr->ndih + 2);
+    srenew(xr->dih, xr->ndih + 2LL);
     for (i = 0; (i < 4); i++)
     {
         xr->dih[xr->ndih].ai[i] = ff[i];
@@ -131,7 +131,7 @@ static void add_xr(t_xrama* xr, const int ff[5], const t_atoms* atoms)
     }
     xr->ndih += 2;
 
-    srenew(xr->pp, xr->npp + 1);
+    srenew(xr->pp, xr->npp + 1LL);
     xr->pp[xr->npp].iphi  = xr->ndih - 2;
     xr->pp[xr->npp].ipsi  = xr->ndih - 1;
     xr->pp[xr->npp].bShow = FALSE;
@@ -178,7 +178,9 @@ static void min_max(t_xrama* xr)
     {
         for (j = 0; (j < 4); j++)
         {
+            MSVC_DIAGNOSTIC_IGNORE(28182) // false positive in 2019 (16.5.4)
             ai = xr->dih[i].ai[j];
+            MSVC_DIAGNOSTIC_RESET
             if (ai < xr->amin)
             {
                 xr->amin = ai;
@@ -219,7 +221,7 @@ static void get_dih_props(t_xrama* xr, const t_idef* idef, int mult)
         }
 
         i += nra + 1;
-        ia += nra + 1;
+        ia += nra + 1LL;
     }
     /* Fill in defaults for values not in the topology */
     for (i = 0; (i < xr->ndih); i++)
index a8326a3becafeb892cfd2cd79b01fa74dfd9c24a..1e68c14dae2d16a9b0f4fb8a75a89773bc1af4be 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -243,7 +243,7 @@ public:
     //! Returns the number of cells in the column
     int numCellsInColumn(int columnIndex) const
     {
-        return cxy_ind_[columnIndex + 1] - cxy_ind_[columnIndex];
+        return cxy_ind_[columnIndex + 1LL] - cxy_ind_[columnIndex];
     }
 
     //! Returns the index of the first atom in the column
index 89a34776391caa3f252bb9100e5cdd2524c7ea80..26a9bba0da94ffef9ec382aec0e1dd9f8b3581b3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -185,6 +185,7 @@ static KernelSetup pick_nbnxn_kernel_cpu(const t_inputrec gmx_unused* ir,
          * On AMD Zen, tabulated Ewald kernels are faster on all 4 combinations
          * of single or double precision and 128 or 256-bit AVX2.
          */
+        MSVC_DIAGNOSTIC_IGNORE(6285) // Always zero because compile time constant
         if (
 #if GMX_SIMD
                 (GMX_SIMD_REAL_WIDTH >= 8 || (GMX_SIMD_REAL_WIDTH >= 4 && GMX_SIMD_HAVE_FMA && !GMX_DOUBLE)) &&
@@ -193,10 +194,8 @@ static KernelSetup pick_nbnxn_kernel_cpu(const t_inputrec gmx_unused* ir,
         {
             kernelSetup.ewaldExclusionType = EwaldExclusionType::Analytical;
         }
-        else
-        {
-            kernelSetup.ewaldExclusionType = EwaldExclusionType::Table;
-        }
+        MSVC_DIAGNOSTIC_RESET
+        else { kernelSetup.ewaldExclusionType = EwaldExclusionType::Table; }
         if (getenv("GMX_NBNXN_EWALD_TABLE") != nullptr)
         {
             kernelSetup.ewaldExclusionType = EwaldExclusionType::Table;
index d59e488e4428ee9028f8ff9fe08a0c19e1742493..6632ae84bf37d1148728a3530293126df1b952b4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -155,6 +155,7 @@ typedef struct
 struct nbnxn_excl_t
 {
     /* Constructor, sets no exclusions, so all atom pairs interacting */
+    MSVC_DIAGNOSTIC_IGNORE(26495) // pair is not being initialized!
     nbnxn_excl_t()
     {
         for (unsigned int& pairEntry : pair)
@@ -162,6 +163,7 @@ struct nbnxn_excl_t
             pairEntry = NBNXN_INTERACTION_MASK_ALL;
         }
     }
+    MSVC_DIAGNOSTIC_RESET
 
     /* Topology exclusion interaction bits per warp */
     unsigned int pair[c_nbnxnGpuExclSize];
index 692dd8c87742c2639576bf0d7d15e45cbaee86ad..6c5f24ad876909e908fbfcbabab1bc89e00b50d4 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -560,7 +560,7 @@ void OptionStorageTemplate<T>::commitValues()
     {
         store_->append(value);
     }
-    DIAGNOSTIC_RESET;
+    CLANG_DIAGNOSTIC_RESET;
     clearSet();
 }
 
index b514aa0f94d3f015c1241eedabce48b6bcc1dccb..76ecda428577cb6c48008a0afd807710ddeca708 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2017,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2017,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -49,8 +49,9 @@ namespace gmx
 class SimdFIBool
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     SimdFIBool() {}
-
+    MSVC_DIAGNOSTIC_RESET
     SimdFIBool(bool b) : simdInternal_(_mm256_set1_epi32(b ? 0xFFFFFFFF : 0)) {}
 
     // Internal utility constructor to simplify return statements
index fbdbf9819e214eca5ed6aa373a04944f618b9fca..9969e03e1d8fccd0115052ae603d8adc5402797c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2017,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2017,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -49,7 +49,9 @@ namespace gmx
 class Simd4Double
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     Simd4Double() {}
+    MSVC_DIAGNOSTIC_RESET
 
     Simd4Double(double d) : simdInternal_(_mm256_set1_pd(d)) {}
 
@@ -62,7 +64,9 @@ public:
 class Simd4DBool
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     Simd4DBool() {}
+    MSVC_DIAGNOSTIC_RESET
 
     //! \brief Construct from scalar bool
     Simd4DBool(bool b) : simdInternal_(_mm256_castsi256_pd(_mm256_set1_epi32(b ? 0xFFFFFFFF : 0)))
index f3b3a776d7558a776209b726429fcef8ec8fb4e2..e1b902794864c4313af9f56f3b57df8f64fc6567 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -49,8 +49,9 @@ namespace gmx
 class Simd4Float
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     Simd4Float() {}
-
+    MSVC_DIAGNOSTIC_RESET
     Simd4Float(float f) : simdInternal_(_mm_set1_ps(f)) {}
 
     // Internal utility constructor to simplify return statements
@@ -62,8 +63,9 @@ public:
 class Simd4FBool
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     Simd4FBool() {}
-
+    MSVC_DIAGNOSTIC_RESET
     //! \brief Construct from scalar bool
     Simd4FBool(bool b) : simdInternal_(_mm_castsi128_ps(_mm_set1_epi32(b ? 0xFFFFFFFF : 0))) {}
 
index 4b506b1656c89166341dcdd064fdb40001cd9a0f..1ca12e817114c248be9ca6923ceae1b7fed63bb8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -55,8 +55,9 @@ namespace gmx
 class SimdDouble
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     SimdDouble() {}
-
+    MSVC_DIAGNOSTIC_RESET
     SimdDouble(double d) : simdInternal_(_mm256_set1_pd(d)) {}
 
     // Internal utility constructor to simplify return statements
@@ -68,8 +69,9 @@ public:
 class SimdDInt32
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     SimdDInt32() {}
-
+    MSVC_DIAGNOSTIC_RESET
     SimdDInt32(std::int32_t i) : simdInternal_(_mm_set1_epi32(i)) {}
 
     // Internal utility constructor to simplify return statements
@@ -81,8 +83,9 @@ public:
 class SimdDBool
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     SimdDBool() {}
-
+    MSVC_DIAGNOSTIC_RESET
     SimdDBool(bool b) : simdInternal_(_mm256_castsi256_pd(_mm256_set1_epi32(b ? 0xFFFFFFFF : 0))) {}
 
     // Internal utility constructor to simplify return statements
@@ -94,8 +97,9 @@ public:
 class SimdDIBool
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     SimdDIBool() {}
-
+    MSVC_DIAGNOSTIC_RESET
     SimdDIBool(bool b) : simdInternal_(_mm_set1_epi32(b ? 0xFFFFFFFF : 0)) {}
 
     // Internal utility constructor to simplify return statements
index 4137858aac26513df2b20e1f52982231a89fd51d..36496ca3ec5294395942fb58749fe7086ca3a697 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -52,8 +52,9 @@ namespace gmx
 class SimdFloat
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     SimdFloat() {}
-
+    MSVC_DIAGNOSTIC_RESET
     SimdFloat(float f) : simdInternal_(_mm256_set1_ps(f)) {}
 
     // Internal utility constructor to simplify return statements
@@ -65,8 +66,9 @@ public:
 class SimdFInt32
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     SimdFInt32() {}
-
+    MSVC_DIAGNOSTIC_RESET
     SimdFInt32(std::int32_t i) : simdInternal_(_mm256_set1_epi32(i)) {}
 
     // Internal utility constructor to simplify return statements
@@ -78,8 +80,9 @@ public:
 class SimdFBool
 {
 public:
+    MSVC_DIAGNOSTIC_IGNORE(26495) // simdInternal_ is not being initialized!
     SimdFBool() {}
-
+    MSVC_DIAGNOSTIC_RESET
     SimdFBool(bool b) : simdInternal_(_mm256_castsi256_ps(_mm256_set1_epi32(b ? 0xFFFFFFFF : 0))) {}
 
     // Internal utility constructor to simplify return statements
index fc51f4099da88ecf200306d76f83afbdc1bfc0f1..bd9b678e1f8cbd60ed503bdd5ffaa0741232b592 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -78,6 +78,7 @@
 #include <array>
 #include <type_traits>
 
+#include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/classhelpers.h"
 #include "gromacs/utility/real.h"
 
index 8db0164b90c8e6ef9ca008c3666b98b62c1ac3df..db9065a2b2ad221bc8cd5ba04f6bf36a2e1265d1 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010,2014,2015,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014,2015,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -64,7 +64,10 @@ public:
     int numBlocks() const { return static_cast<int>(index_.size()) - 1; }
 
     /*! \brief Returns the size of the block with index \p blockIndex */
-    Block block(int blockIndex) const { return Block(index_[blockIndex], index_[blockIndex + 1]); }
+    Block block(int blockIndex) const
+    {
+        return Block(index_[blockIndex], index_[blockIndex + 1LL]);
+    }
 
     /*! \brief Returns the full range */
     Block fullRange() const { return Block(index_.front(), index_.back()); }
@@ -98,7 +101,7 @@ public:
     void reduceNumBlocks(int newNumBlocks)
     {
         GMX_ASSERT(newNumBlocks <= numBlocks(), "Can only shrink to fewer blocks");
-        index_.resize(newNumBlocks + 1);
+        index_.resize(newNumBlocks + 1LL);
     }
 
     /*! \brief Sets the partitioning to \p numBlocks blocks each of size 1 */
index dd0bb86b00e7c4f5a3a4bc372a89b8f6a1ee65d7..d1ae0c6ce71f26f60b9398f866daf8008be71ff3 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -151,12 +151,22 @@ index ssize(const T& t)
 #    define DO_PRAGMA(x) _Pragma(#    x)
 #    define CLANG_DIAGNOSTIC_IGNORE(warning) \
         _Pragma("clang diagnostic push") DO_PRAGMA(clang diagnostic ignored #warning)
-#    define DIAGNOSTIC_RESET _Pragma("clang diagnostic pop")
+#    define CLANG_DIAGNOSTIC_RESET _Pragma("clang diagnostic pop")
 #else
-//! Ignore specified clang warning until DIAGNOSTIC_RESET
+//! Ignore specified clang warning until CLANG_DIAGNOSTIC_RESET
 #    define CLANG_DIAGNOSTIC_IGNORE(warning)
 //! Reset all diagnostics to default
-#    define DIAGNOSTIC_RESET
+#    define CLANG_DIAGNOSTIC_RESET
+#endif
+
+#ifdef _MSC_VER
+#    define MSVC_DIAGNOSTIC_IGNORE(id) __pragma(warning(push)) __pragma(warning(disable : id))
+#    define MSVC_DIAGNOSTIC_RESET __pragma(warning(pop))
+#else
+//! Ignore specified MSVC warning until MSVC_DIAGNOSTIC_RESET
+#    define MSVC_DIAGNOSTIC_IGNORE(warning)
+//! Reset all diagnostics to default
+#    define MSVC_DIAGNOSTIC_RESET
 #endif
 
 namespace gmx