diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bfd4ca7287..7b80a91a16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -199,7 +199,7 @@ jobs: run: | uv pip install --python=python --system setuptools pytest tests/extra_setuptools - if: "!(matrix.runs-on == 'windows-2022')" + if: matrix.runs-on != 'windows-2022' manylinux: name: Manylinux on 🐍 3.13t • GIL @@ -330,9 +330,10 @@ jobs: container_suffix: "-bullseye" - clang: 18 std: 20 + cxx_flags: "-Werror -Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls" container_suffix: "-bookworm" - name: "🐍 3 • Clang ${{ matrix.clang }} • C++${{ matrix.std }} • x64" + name: "🐍 3 • Clang ${{ matrix.clang }} • C++${{ matrix.std }} • x64${{ matrix.cxx_flags && ' • cxx_flags' || '' }}" container: "silkeh/clang:${{ matrix.clang }}${{ matrix.container_suffix }}" steps: @@ -348,6 +349,7 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=${{ matrix.std }} + -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build @@ -491,9 +493,9 @@ jobs: - { gcc: 9, std: 20 } - { gcc: 10, std: 17 } - { gcc: 10, std: 20 } - - { gcc: 13, std: 20 } + - { gcc: 13, std: 20, cxx_flags: "-Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls" } - name: "🐍 3 • GCC ${{ matrix.gcc }} • C++${{ matrix.std }}• x64" + name: "🐍 3 • GCC ${{ matrix.gcc }} • C++${{ matrix.std }} • x64${{ matrix.cxx_flags && ' • cxx_flags' || '' }}" container: "gcc:${{ matrix.gcc }}" steps: @@ -515,6 +517,7 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=${{ matrix.std }} + -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build diff --git a/include/pybind11/detail/class.h b/include/pybind11/detail/class.h index 98ff61f5d7..08e26f71d0 100644 --- a/include/pybind11/detail/class.h +++ b/include/pybind11/detail/class.h @@ -499,8 +499,13 @@ extern "C" inline void pybind11_object_dealloc(PyObject *self) { Py_DECREF(type); } +PYBIND11_WARNING_PUSH +PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls") + std::string error_string(); +PYBIND11_WARNING_POP + /** Create the type which can be used as a common base for all classes. This is needed in order to satisfy Python's requirements for multiple inheritance. Return value: New reference. */ diff --git a/include/pybind11/detail/function_record_pyobject.h b/include/pybind11/detail/function_record_pyobject.h index 4cc8b242e8..13895b96f2 100644 --- a/include/pybind11/detail/function_record_pyobject.h +++ b/include/pybind11/detail/function_record_pyobject.h @@ -173,9 +173,6 @@ inline int tp_init_impl(PyObject *, PyObject *, PyObject *) { // return -1; // Unreachable. } -// The implementation needs the definition of `class cpp_function`. -void tp_dealloc_impl(PyObject *self); - inline void tp_free_impl(void *) { pybind11_fail("UNEXPECTED CALL OF function_record_PyTypeObject_methods::tp_free_impl"); } diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index d4f9a41e0c..d4ce1a492a 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h @@ -511,9 +511,14 @@ inline PyThreadState *get_thread_state_unchecked() { void keep_alive_impl(handle nurse, handle patient); inline PyObject *make_new_instance(PyTypeObject *type); +PYBIND11_WARNING_PUSH +PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls") + // PYBIND11:REMINDER: Needs refactoring of existing pybind11 code. inline bool deregister_instance(instance *self, void *valptr, const type_info *tinfo); +PYBIND11_WARNING_POP + PYBIND11_NAMESPACE_BEGIN(smart_holder_type_caster_support) struct value_and_holder_helper { diff --git a/include/pybind11/gil.h b/include/pybind11/gil.h index 3f2c28f452..1a9bfeaddf 100644 --- a/include/pybind11/gil.h +++ b/include/pybind11/gil.h @@ -32,9 +32,14 @@ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) PYBIND11_NAMESPACE_BEGIN(detail) +PYBIND11_WARNING_PUSH +PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls") + // forward declarations PyThreadState *get_thread_state_unchecked(); +PYBIND11_WARNING_POP + PYBIND11_NAMESPACE_END(detail) /* The functions below essentially reproduce the PyGILState_* API using a RAII diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e5e613df48..69976f745a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -363,7 +363,7 @@ elseif(MSVC) else() file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - "#include \nint main(int argc, char ** argv) {\n std::filesystem::path p(argv[0]);\n return p.string().length();\n}" + "#include \nint main(int /*argc*/, char ** argv) {\n std::filesystem::path p(argv[0]);\n return p.string().length();\n}" ) try_compile( STD_FS_NO_LIB_NEEDED ${CMAKE_CURRENT_BINARY_DIR}