Add -DPYBIND11_WERROR=ON to mingw cmake commands (#4073)

* Add `-DPYBIND11_WERROR=ON` to mingw cmake commands (and `-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON`).

* Using no-destructor idiom to side-step overzealous MINGW warning.

* Add __MINGW32__ pragma GCC diagnostic ignored in eigen.h

* Add another no-destructor workaround.

* Temporarily add -k (keep-going) flags to hopefully speed up finding all warnings.

* Revert "Temporarily add -k (keep-going) flags to hopefully speed up finding all warnings."

This reverts commit f36b0af8f9.

* Very minor shuffle to avoid MSVC warnings.

* Remove all `:BOOL` as suggested by @henryiii
This commit is contained in:
Ralf W. Grosse-Kunstleve 2022-08-01 06:18:48 -07:00 committed by GitHub
parent 1e3400b674
commit 3665530264
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 7 deletions

View File

@ -911,7 +911,7 @@ jobs:
- name: Configure C++11 - name: Configure C++11
# LTO leads to many undefined reference like # LTO leads to many undefined reference like
# `pybind11::detail::function_call::function_call(pybind11::detail::function_call&&) # `pybind11::detail::function_call::function_call(pybind11::detail::function_call&&)
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DDOWNLOAD_CATCH=ON -S . -B build run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build
- name: Build C++11 - name: Build C++11
run: cmake --build build -j 2 run: cmake --build build -j 2
@ -929,7 +929,7 @@ jobs:
run: git clean -fdx run: git clean -fdx
- name: Configure C++14 - name: Configure C++14
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DDOWNLOAD_CATCH=ON -S . -B build2 run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build2
- name: Build C++14 - name: Build C++14
run: cmake --build build2 -j 2 run: cmake --build build2 -j 2
@ -947,7 +947,7 @@ jobs:
run: git clean -fdx run: git clean -fdx
- name: Configure C++17 - name: Configure C++17
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DDOWNLOAD_CATCH=ON -S . -B build3 run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build3
- name: Build C++17 - name: Build C++17
run: cmake --build build3 -j 2 run: cmake --build build3 -j 2

View File

@ -27,6 +27,9 @@
# pragma warning(disable : 4127) // C4127: conditional expression is constant # pragma warning(disable : 4127) // C4127: conditional expression is constant
# pragma warning(disable : 5054) // https://github.com/pybind/pybind11/pull/3741 # pragma warning(disable : 5054) // https://github.com/pybind/pybind11/pull/3741
// C5054: operator '&': deprecated between enumerations of different types // C5054: operator '&': deprecated between enumerations of different types
#elif defined(__MINGW32__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif #endif
#include <Eigen/Core> #include <Eigen/Core>
@ -34,6 +37,8 @@
#if defined(_MSC_VER) #if defined(_MSC_VER)
# pragma warning(pop) # pragma warning(pop)
#elif defined(__MINGW32__)
# pragma GCC diagnostic pop
#endif #endif
// Eigen prior to 3.2.7 doesn't have proper move constructors--but worse, some classes get implicit // Eigen prior to 3.2.7 doesn't have proper move constructors--but worse, some classes get implicit

View File

@ -266,9 +266,14 @@ TEST_SUBMODULE(builtin_casters, m) {
}); });
m.def("lvalue_nested", []() -> const decltype(lvnested) & { return lvnested; }); m.def("lvalue_nested", []() -> const decltype(lvnested) & { return lvnested; });
static std::pair<int, std::string> int_string_pair{2, "items"};
m.def( m.def(
"int_string_pair", []() { return &int_string_pair; }, py::return_value_policy::reference); "int_string_pair",
[]() {
// Using no-destructor idiom to side-step warnings from overzealous compilers.
static auto *int_string_pair = new std::pair<int, std::string>{2, "items"};
return int_string_pair;
},
py::return_value_policy::reference);
// test_builtins_cast_return_none // test_builtins_cast_return_none
m.def("return_none_string", []() -> std::string * { return nullptr; }); m.def("return_none_string", []() -> std::string * { return nullptr; });

View File

@ -176,9 +176,14 @@ TEST_SUBMODULE(stl, m) {
m.def("load_bool_vector", m.def("load_bool_vector",
[](const std::vector<bool> &v) { return v.at(0) == true && v.at(1) == false; }); [](const std::vector<bool> &v) { return v.at(0) == true && v.at(1) == false; });
// Unnumbered regression (caused by #936): pointers to stl containers aren't castable // Unnumbered regression (caused by #936): pointers to stl containers aren't castable
static std::vector<RValueCaster> lvv{2};
m.def( m.def(
"cast_ptr_vector", []() { return &lvv; }, py::return_value_policy::reference); "cast_ptr_vector",
[]() {
// Using no-destructor idiom to side-step warnings from overzealous compilers.
static auto *v = new std::vector<RValueCaster>{2};
return v;
},
py::return_value_policy::reference);
// test_deque // test_deque
m.def("cast_deque", []() { return std::deque<int>{1}; }); m.def("cast_deque", []() { return std::deque<int>{1}; });
@ -237,6 +242,7 @@ TEST_SUBMODULE(stl, m) {
lvn["b"].emplace_back(); // add a list lvn["b"].emplace_back(); // add a list
lvn["b"].back().emplace_back(); // add an array lvn["b"].back().emplace_back(); // add an array
lvn["b"].back().emplace_back(); // add another array lvn["b"].back().emplace_back(); // add another array
static std::vector<RValueCaster> lvv{2};
m.def("cast_lv_vector", []() -> const decltype(lvv) & { return lvv; }); m.def("cast_lv_vector", []() -> const decltype(lvv) & { return lvv; });
m.def("cast_lv_array", []() -> const decltype(lva) & { return lva; }); m.def("cast_lv_array", []() -> const decltype(lva) & { return lva; });
m.def("cast_lv_map", []() -> const decltype(lvm) & { return lvm; }); m.def("cast_lv_map", []() -> const decltype(lvm) & { return lvm; });