Continue fixing warnings with clang as host compiler
authorMark Abraham <mark.j.abraham@gmail.com>
Mon, 21 Jun 2021 07:57:13 +0000 (07:57 +0000)
committerPaul Bauer <paul.bauer.q@gmail.com>
Mon, 21 Jun 2021 07:57:13 +0000 (07:57 +0000)
src/gromacs/CMakeLists.txt
src/testutils/TestMacros.cmake

index ada2664563925d077b0dd42444aa5e67cffd2a29..464620dbe53adf2852907e85b60c5490484d46f2 100644 (file)
@@ -279,11 +279,6 @@ endif()
 # Do any special handling needed for .cpp files that use
 # CUDA runtime headers
 if (GMX_GPU_CUDA AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-    # CUDA header cuda_runtime_api.h in at least CUDA 10.1 uses 0
-    # where nullptr would be preferable. GROMACS can't fix these, so
-    # must suppress them.
-    GMX_TEST_CXXFLAG(CXXFLAGS_NO_ZERO_AS_NULL_POINTER_CONSTANT "-Wno-zero-as-null-pointer-constant" NVCC_CLANG_SUPPRESSIONS_CXXFLAGS)
-
     foreach(_compile_flag ${NVCC_CLANG_SUPPRESSIONS_CXXFLAGS})
         set(GMX_CUDA_CLANG_FLAGS "${GMX_CUDA_CLANG_FLAGS} ${_compile_flag}")
     endforeach()
index c6da3bfb5f799c2d017739e22b31a3abff7bcb3f..fd400aa4c07a6a2acc040ec524189c6d5ddf1f56 100644 (file)
@@ -53,6 +53,11 @@ function (gmx_add_unit_test_library NAME)
             # Some false positives exist produced by GoogleTest implementation
             gmx_target_warning_suppression(${NAME} "-Wno-zero-as-null-pointer-constant" HAS_WARNING_NO_ZERO_AS_NULL_POINTER_CONSTANT)
             gmx_target_warning_suppression(${NAME} "-Wno-gnu-zero-variadic-macro-arguments" HAS_WARNING_NO_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS)
+            if(GMX_GPU_CUDA)
+                # CUDA headers target C, so use old-style casts that clang
+                # warns about when it is the host compiler
+                gmx_target_warning_suppression(${NAME} "-Wno-old-style-cast" HAS_NO_OLD_STYLE_CAST)
+            endif()
         endif()
     endif()
 endfunction ()
@@ -183,6 +188,11 @@ function (gmx_add_gtest_executable EXENAME)
             # Some false positives exist produced by GoogleTest implementation
             gmx_target_warning_suppression(${EXENAME} "-Wno-zero-as-null-pointer-constant" HAS_WARNING_NO_ZERO_AS_NULL_POINTER_CONSTANT)
             gmx_target_warning_suppression(${EXENAME} "-Wno-gnu-zero-variadic-macro-arguments" HAS_WARNING_NO_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS)
+            if(GMX_GPU_CUDA)
+                # CUDA headers target C, so use old-style casts that clang
+                # warns about when it is the host compiler
+                gmx_target_warning_suppression(${EXENAME} "-Wno-old-style-cast" HAS_NO_OLD_STYLE_CAST)
+            endif()
         endif()
     endif()
 endfunction()