From 37cd50005340e43d715cbd87db2095e6483cc539 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 20 Aug 2024 16:53:44 -0400 Subject: [PATCH] fix: allow -Wpedantic again Signed-off-by: Henry Schreiner --- docs/advanced/cast/stl.rst | 6 +++--- include/pybind11/detail/common.h | 3 +++ tests/CMakeLists.txt | 1 + tests/local_bindings.h | 16 ++++++++-------- tests/test_callbacks.cpp | 2 +- tests/test_eigen_matrix.cpp | 2 +- tests/test_opaque_types.cpp | 2 +- tests/test_sequences_and_iterators.cpp | 4 ++-- tests/test_stl.cpp | 2 +- 9 files changed, 21 insertions(+), 17 deletions(-) diff --git a/docs/advanced/cast/stl.rst b/docs/advanced/cast/stl.rst index 03d49b2950..42b85532d8 100644 --- a/docs/advanced/cast/stl.rst +++ b/docs/advanced/cast/stl.rst @@ -162,7 +162,7 @@ the declaration .. code-block:: cpp - PYBIND11_MAKE_OPAQUE(std::vector); + PYBIND11_MAKE_OPAQUE(std::vector) before any binding code (e.g. invocations to ``class_::def()``, etc.). This macro must be specified at the top level (and outside of any namespaces), since @@ -207,8 +207,8 @@ The following example showcases usage of :file:`pybind11/stl_bind.h`: // Don't forget this #include - PYBIND11_MAKE_OPAQUE(std::vector); - PYBIND11_MAKE_OPAQUE(std::map); + PYBIND11_MAKE_OPAQUE(std::vector) + PYBIND11_MAKE_OPAQUE(std::map) // ... diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 643fd33d7e..2a39e88f37 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -479,6 +479,8 @@ PYBIND11_WARNING_POP } \endrst */ +PYBIND11_WARNING_PUSH +PYBIND11_WARNING_DISABLE_CLANG("-Wgnu-zero-variadic-macro-arguments") #define PYBIND11_MODULE(name, variable, ...) \ static ::pybind11::module_::module_def PYBIND11_CONCAT(pybind11_module_def_, name) \ PYBIND11_MAYBE_UNUSED; \ @@ -499,6 +501,7 @@ PYBIND11_WARNING_POP PYBIND11_CATCH_INIT_EXCEPTIONS \ } \ void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ & (variable)) +PYBIND11_WARNING_POP PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 18308731ab..bfc2e94df9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -377,6 +377,7 @@ function(pybind11_enable_warnings target_name) ${target_name} PRIVATE -Wall -Wextra + -Wpedantic -Wconversion -Wcast-qual -Wdeprecated diff --git a/tests/local_bindings.h b/tests/local_bindings.h index 01d2785353..7e109d915d 100644 --- a/tests/local_bindings.h +++ b/tests/local_bindings.h @@ -56,13 +56,13 @@ class LocalSimpleException : public std::exception { std::string message = ""; }; -PYBIND11_MAKE_OPAQUE(LocalVec); -PYBIND11_MAKE_OPAQUE(LocalVec2); -PYBIND11_MAKE_OPAQUE(LocalMap); -PYBIND11_MAKE_OPAQUE(NonLocalVec); -// PYBIND11_MAKE_OPAQUE(NonLocalVec2); // same type as LocalVec2 -PYBIND11_MAKE_OPAQUE(NonLocalMap); -PYBIND11_MAKE_OPAQUE(NonLocalMap2); +PYBIND11_MAKE_OPAQUE(LocalVec) +PYBIND11_MAKE_OPAQUE(LocalVec2) +PYBIND11_MAKE_OPAQUE(LocalMap) +PYBIND11_MAKE_OPAQUE(NonLocalVec) +// PYBIND11_MAKE_OPAQUE(NonLocalVec2) +PYBIND11_MAKE_OPAQUE(NonLocalMap) +PYBIND11_MAKE_OPAQUE(NonLocalMap2) // Simple bindings (used with the above): template @@ -70,7 +70,7 @@ py::class_ bind_local(Args &&...args) { return py::class_(std::forward(args)...).def(py::init()).def("get", [](T &i) { return i.i + Adjust; }); -}; +} // Simulate a foreign library base class (to match the example in the docs): namespace pets { diff --git a/tests/test_callbacks.cpp b/tests/test_callbacks.cpp index 2fd05dec72..e303e76567 100644 --- a/tests/test_callbacks.cpp +++ b/tests/test_callbacks.cpp @@ -148,7 +148,7 @@ TEST_SUBMODULE(callbacks, m) { m.def("dummy_function2", [](int i, int j) { return i + j; }); m.def( "roundtrip", - [](std::function f, bool expect_none = false) { + [](std::function f, bool expect_none) { if (expect_none && f) { throw std::runtime_error("Expected None to be converted to empty std::function"); } diff --git a/tests/test_eigen_matrix.cpp b/tests/test_eigen_matrix.cpp index 21261bfc2f..fd116e080e 100644 --- a/tests/test_eigen_matrix.cpp +++ b/tests/test_eigen_matrix.cpp @@ -76,7 +76,7 @@ struct CustomOperatorNew { Eigen::Matrix4d a = Eigen::Matrix4d::Zero(); Eigen::Matrix4d b = Eigen::Matrix4d::Identity(); - EIGEN_MAKE_ALIGNED_OPERATOR_NEW; + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; TEST_SUBMODULE(eigen_matrix, m) { diff --git a/tests/test_opaque_types.cpp b/tests/test_opaque_types.cpp index 154d0a8d31..da3866cd00 100644 --- a/tests/test_opaque_types.cpp +++ b/tests/test_opaque_types.cpp @@ -18,7 +18,7 @@ // This also deliberately doesn't use the below StringList type alias to test // that MAKE_OPAQUE can handle a type containing a `,`. (The `std::allocator` // bit is just the default `std::vector` allocator). -PYBIND11_MAKE_OPAQUE(std::vector>); +PYBIND11_MAKE_OPAQUE(std::vector>) using StringList = std::vector>; diff --git a/tests/test_sequences_and_iterators.cpp b/tests/test_sequences_and_iterators.cpp index 4a1d37f4de..c997b73001 100644 --- a/tests/test_sequences_and_iterators.cpp +++ b/tests/test_sequences_and_iterators.cpp @@ -86,8 +86,8 @@ class NonCopyableInt { }; using NonCopyableIntPair = std::pair; -PYBIND11_MAKE_OPAQUE(std::vector); -PYBIND11_MAKE_OPAQUE(std::vector); +PYBIND11_MAKE_OPAQUE(std::vector) +PYBIND11_MAKE_OPAQUE(std::vector) template py::list test_random_access_iterator(PythonType x) { diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 6240524a09..dd93d51d0a 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -59,7 +59,7 @@ struct visit_helper { } // namespace PYBIND11_NAMESPACE #endif -PYBIND11_MAKE_OPAQUE(std::vector>); +PYBIND11_MAKE_OPAQUE(std::vector>) /// Issue #528: templated constructor struct TplCtorClass {