Suppress clang warnings about QMMM code
authorMark Abraham <mark.j.abraham@gmail.com>
Wed, 7 Nov 2018 12:37:14 +0000 (13:37 +0100)
committerSzilárd Páll <pall.szilard@gmail.com>
Wed, 7 Nov 2018 18:17:32 +0000 (19:17 +0100)
These are typically not configured, and the resulting dead code and
possible noreturn attributes are more trouble than they are worth,
particularly when other compilers then get confused.

Change-Id: Idf51ee7c0a8c34d71d204db405f18704002acb58

cmake/gmxCFlags.cmake
src/gromacs/mdlib/qmmm.cpp
src/gromacs/mimic/MimicCommunicator.cpp

index 4cce7cf7a137fee52c1e5f42c63eace0ea35b0aa..ea33f6a872fe02443a636340106da28b44d14c35 100644 (file)
@@ -301,11 +301,12 @@ GMX_TEST_CFLAG(CFLAGS_WARN "/W3 /wd177 /wd411 /wd593 /wd981 /wd1418 /wd1419 /wd1
         #      unreferenced local variable (only C)
         #      conversion from 'size_t' to 'int', possible loss of data
         #      conversion from 'const char*' to 'void*', different 'const' qualifiers (only C)
+        #      unknown pragma (4068)
         if(NOT CMAKE_CONFIGURATION_TYPES)
-            GMX_TEST_CFLAG(CFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4101 /wd4267 /wd4090" GMXC_CFLAGS)
-            GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4267" GMXC_CXXFLAGS)
-        else() #Projects only use the C++ flags
-            GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4101 /wd4267 /wd4090" GMXC_CXXFLAGS)
+            GMX_TEST_CFLAG(CFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4101 /wd4267 /wd4090 /wd4068" GMXC_CFLAGS)
+            GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4267 /wd4068" GMXC_CXXFLAGS)
+        else() # MSVC projects only use the C++ flags
+            GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800 /wd4355 /wd4996 /wd4305 /wd4244 /wd4101 /wd4267 /wd4090 /wd4068" GMXC_CXXFLAGS)
         endif()
     endif()
 
index aeb4a4ecf32318666090e8fd9f9d2d9e80d2e295..95c2ea920683237293de7f3c93f4ab13e9c4b461 100644 (file)
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
 
+// When not built in a configuration with QMMM support, much of this
+// code is unreachable by design. Tell clang not to warn about it.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunreachable-code"
+
 /* this struct and these comparison functions are needed for creating
  * a QMMM input for the QM routines from the QMMM neighbor list.
  */
@@ -978,3 +983,5 @@ real calculate_QMMM(const t_commrec  *cr,
     }
     return(QMener);
 } /* calculate_QMMM */
+
+#pragma GCC diagnostic pop
index bf75df1b6ee04e4b90037eaac1372f9f3c9b3f2c..cb4bca655595f7ae0699006a45f36945144a6491 100644 (file)
 #include <MessageApi.h>
 #endif
 
+// When not built in a configuration with QMMM support, much of this
+// code is unreachable by design. Tell clang not to warn about it.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmissing-noreturn"
+
 #if !GMX_MIMIC
 //! \brief Definitions to stub the ones defined in DataTypes.h
 constexpr int TYPE_INT = 0, TYPE_DOUBLE = 0;
@@ -268,3 +273,5 @@ void gmx::MimicCommunicator::finalize()
 {
     MCL_destroy();
 }
+
+#pragma GCC diagnostic pop