From 40d77f7a07188d732b077a159bd26891ec565b3d Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 23 Feb 2021 20:27:27 -0800 Subject: [PATCH 1/3] Moving large `pragma warning` block from pybind11.h to detail/common.h (fixes MSVC and GCC failures after iwyu cleanup under PR #2672). --- include/pybind11/detail/common.h | 32 ++++++++++++++++++++++++++++++++ include/pybind11/pybind11.h | 32 -------------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 1f7446103e..47a16b380b 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -13,6 +13,38 @@ #define PYBIND11_VERSION_MINOR 6 #define PYBIND11_VERSION_PATCH 3.dev1 +#if defined(__INTEL_COMPILER) +# pragma warning push +# pragma warning disable 68 // integer conversion resulted in a change of sign +# pragma warning disable 186 // pointless comparison of unsigned integer with zero +# pragma warning disable 878 // incompatible exception specifications +# pragma warning disable 1334 // the "template" keyword used for syntactic disambiguation may only be used within a template +# pragma warning disable 1682 // implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem) +# pragma warning disable 1786 // function "strdup" was declared deprecated +# pragma warning disable 1875 // offsetof applied to non-POD (Plain Old Data) types is nonstandard +# pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline" +#elif defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter +# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant +# pragma warning(disable: 4512) // warning C4512: Assignment operator was implicitly defined as deleted +# pragma warning(disable: 4800) // warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) +# pragma warning(disable: 4996) // warning C4996: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name +# pragma warning(disable: 4702) // warning C4702: unreachable code +# pragma warning(disable: 4522) // warning C4522: multiple assignment operators specified +# pragma warning(disable: 4505) // warning C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only) +#elif defined(__GNUG__) && !defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-but-set-parameter" +# pragma GCC diagnostic ignored "-Wunused-but-set-variable" +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +# pragma GCC diagnostic ignored "-Wstrict-aliasing" +# pragma GCC diagnostic ignored "-Wattributes" +# if __GNUC__ >= 7 +# pragma GCC diagnostic ignored "-Wnoexcept-type" +# endif +#endif + #define PYBIND11_NAMESPACE_BEGIN(name) namespace name { #define PYBIND11_NAMESPACE_END(name) } diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 616fa70255..fdaec89826 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -10,38 +10,6 @@ #pragma once -#if defined(__INTEL_COMPILER) -# pragma warning push -# pragma warning disable 68 // integer conversion resulted in a change of sign -# pragma warning disable 186 // pointless comparison of unsigned integer with zero -# pragma warning disable 878 // incompatible exception specifications -# pragma warning disable 1334 // the "template" keyword used for syntactic disambiguation may only be used within a template -# pragma warning disable 1682 // implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem) -# pragma warning disable 1786 // function "strdup" was declared deprecated -# pragma warning disable 1875 // offsetof applied to non-POD (Plain Old Data) types is nonstandard -# pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline" -#elif defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter -# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant -# pragma warning(disable: 4512) // warning C4512: Assignment operator was implicitly defined as deleted -# pragma warning(disable: 4800) // warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) -# pragma warning(disable: 4996) // warning C4996: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name -# pragma warning(disable: 4702) // warning C4702: unreachable code -# pragma warning(disable: 4522) // warning C4522: multiple assignment operators specified -# pragma warning(disable: 4505) // warning C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only) -#elif defined(__GNUG__) && !defined(__clang__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-but-set-parameter" -# pragma GCC diagnostic ignored "-Wunused-but-set-variable" -# pragma GCC diagnostic ignored "-Wmissing-field-initializers" -# pragma GCC diagnostic ignored "-Wstrict-aliasing" -# pragma GCC diagnostic ignored "-Wattributes" -# if __GNUC__ >= 7 -# pragma GCC diagnostic ignored "-Wnoexcept-type" -# endif -#endif - #include "attr.h" #include "gil.h" #include "options.h" From b68607e9518a16f3f8029b49af9dc2e6521966e1 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 30 Apr 2021 17:35:32 -0700 Subject: [PATCH 2/3] Splitting out include/pybind11/detail/pragma_warning_block.h --- CMakeLists.txt | 1 + include/pybind11/detail/common.h | 32 ------------------ .../pybind11/detail/pragma_warning_block.h | 33 +++++++++++++++++++ include/pybind11/pybind11.h | 4 +++ tests/extra_python_package/test_files.py | 1 + 5 files changed, 39 insertions(+), 32 deletions(-) create mode 100644 include/pybind11/detail/pragma_warning_block.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c988ea0b50..68cabadf91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,6 +105,7 @@ set(PYBIND11_HEADERS include/pybind11/detail/descr.h include/pybind11/detail/init.h include/pybind11/detail/internals.h + include/pybind11/detail/pragma_warning_block.h include/pybind11/detail/type_caster_base.h include/pybind11/detail/typeid.h include/pybind11/attr.h diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 47a16b380b..1f7446103e 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -13,38 +13,6 @@ #define PYBIND11_VERSION_MINOR 6 #define PYBIND11_VERSION_PATCH 3.dev1 -#if defined(__INTEL_COMPILER) -# pragma warning push -# pragma warning disable 68 // integer conversion resulted in a change of sign -# pragma warning disable 186 // pointless comparison of unsigned integer with zero -# pragma warning disable 878 // incompatible exception specifications -# pragma warning disable 1334 // the "template" keyword used for syntactic disambiguation may only be used within a template -# pragma warning disable 1682 // implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem) -# pragma warning disable 1786 // function "strdup" was declared deprecated -# pragma warning disable 1875 // offsetof applied to non-POD (Plain Old Data) types is nonstandard -# pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline" -#elif defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter -# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant -# pragma warning(disable: 4512) // warning C4512: Assignment operator was implicitly defined as deleted -# pragma warning(disable: 4800) // warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) -# pragma warning(disable: 4996) // warning C4996: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name -# pragma warning(disable: 4702) // warning C4702: unreachable code -# pragma warning(disable: 4522) // warning C4522: multiple assignment operators specified -# pragma warning(disable: 4505) // warning C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only) -#elif defined(__GNUG__) && !defined(__clang__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-but-set-parameter" -# pragma GCC diagnostic ignored "-Wunused-but-set-variable" -# pragma GCC diagnostic ignored "-Wmissing-field-initializers" -# pragma GCC diagnostic ignored "-Wstrict-aliasing" -# pragma GCC diagnostic ignored "-Wattributes" -# if __GNUC__ >= 7 -# pragma GCC diagnostic ignored "-Wnoexcept-type" -# endif -#endif - #define PYBIND11_NAMESPACE_BEGIN(name) namespace name { #define PYBIND11_NAMESPACE_END(name) } diff --git a/include/pybind11/detail/pragma_warning_block.h b/include/pybind11/detail/pragma_warning_block.h new file mode 100644 index 0000000000..e8ce12bf38 --- /dev/null +++ b/include/pybind11/detail/pragma_warning_block.h @@ -0,0 +1,33 @@ +#pragma once + +#if defined(__INTEL_COMPILER) +# pragma warning push +# pragma warning disable 68 // integer conversion resulted in a change of sign +# pragma warning disable 186 // pointless comparison of unsigned integer with zero +# pragma warning disable 878 // incompatible exception specifications +# pragma warning disable 1334 // the "template" keyword used for syntactic disambiguation may only be used within a template +# pragma warning disable 1682 // implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem) +# pragma warning disable 1786 // function "strdup" was declared deprecated +# pragma warning disable 1875 // offsetof applied to non-POD (Plain Old Data) types is nonstandard +# pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline" +#elif defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter +# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant +# pragma warning(disable: 4512) // warning C4512: Assignment operator was implicitly defined as deleted +# pragma warning(disable: 4800) // warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) +# pragma warning(disable: 4996) // warning C4996: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name +# pragma warning(disable: 4702) // warning C4702: unreachable code +# pragma warning(disable: 4522) // warning C4522: multiple assignment operators specified +# pragma warning(disable: 4505) // warning C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only) +#elif defined(__GNUG__) && !defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-but-set-parameter" +# pragma GCC diagnostic ignored "-Wunused-but-set-variable" +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +# pragma GCC diagnostic ignored "-Wstrict-aliasing" +# pragma GCC diagnostic ignored "-Wattributes" +# if __GNUC__ >= 7 +# pragma GCC diagnostic ignored "-Wnoexcept-type" +# endif +#endif diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index fdaec89826..c289966cc5 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -10,6 +10,10 @@ #pragma once +// Legacy pragma warning block moved to separate file, to enable iwyu cleanup of newly developed +// code, without having to open up this can of worms. #HelpAppreciated cleaning this up. +#include "detail/pragma_warning_block.h" + #include "attr.h" #include "gil.h" #include "options.h" diff --git a/tests/extra_python_package/test_files.py b/tests/extra_python_package/test_files.py index c1d12ed76b..1149afead2 100644 --- a/tests/extra_python_package/test_files.py +++ b/tests/extra_python_package/test_files.py @@ -42,6 +42,7 @@ "include/pybind11/detail/descr.h", "include/pybind11/detail/init.h", "include/pybind11/detail/internals.h", + "include/pybind11/detail/pragma_warning_block.h", "include/pybind11/detail/type_caster_base.h", "include/pybind11/detail/typeid.h", } From 9417ffe1ccc4a97f1b47f4f4a1efeab461d78d01 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 10 Jul 2021 17:01:54 -0700 Subject: [PATCH 3/3] Rollback (experiment) of DOWNLOAD_CATCH=OFF change merged via PR #3059. --- .github/workflows/ci.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fa4303d9b..03c9225c12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,7 +100,7 @@ jobs: run: > cmake -S . -B . -DPYBIND11_WERROR=ON - -DDOWNLOAD_CATCH=OFF + -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_STANDARD=11 ${{ matrix.args }} @@ -111,10 +111,10 @@ jobs: - name: Python tests C++11 run: cmake --build . --target pytest -j 2 - #- name: C++11 tests - # # TODO: Figure out how to load the DLL on Python 3.8+ - # if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))" - # run: cmake --build . --target cpptest -j 2 + - name: C++11 tests + # TODO: Figure out how to load the DLL on Python 3.8+ + if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))" + run: cmake --build . --target cpptest -j 2 - name: Interface test C++11 run: cmake --build . --target test_cmake_build @@ -127,7 +127,7 @@ jobs: run: > cmake -S . -B build2 -DPYBIND11_WERROR=ON - -DDOWNLOAD_CATCH=OFF + -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_STANDARD=17 ${{ matrix.args }} @@ -139,10 +139,10 @@ jobs: - name: Python tests run: cmake --build build2 --target pytest - #- name: C++ tests - # # TODO: Figure out how to load the DLL on Python 3.8+ - # if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))" - # run: cmake --build build2 --target cpptest + - name: C++ tests + # TODO: Figure out how to load the DLL on Python 3.8+ + if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))" + run: cmake --build build2 --target cpptest - name: Interface test run: cmake --build build2 --target test_cmake_build @@ -754,7 +754,7 @@ jobs: cmake -S . -B build -G "Visual Studio 16 2019" -A Win32 -DPYBIND11_WERROR=ON - -DDOWNLOAD_CATCH=OFF + -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON ${{ matrix.args }} - name: Build C++11 @@ -800,7 +800,7 @@ jobs: cmake -S . -B build -G "Visual Studio 14 2015" -A x64 -DPYBIND11_WERROR=ON - -DDOWNLOAD_CATCH=OFF + -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON - name: Build C++14 @@ -849,7 +849,7 @@ jobs: cmake -S . -B build -G "Visual Studio 15 2017" -A x64 -DPYBIND11_WERROR=ON - -DDOWNLOAD_CATCH=OFF + -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_STANDARD=${{ matrix.std }} ${{ matrix.args }}