diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e09540b3e8..75124412ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -217,7 +217,7 @@ jobs: run: | pip install setuptools pytest tests/extra_setuptools - if: "!(matrix.runs-on == 'windows-2022')" + if: matrix.runs-on != 'windows-2022' manylinux: name: Manylinux on 🐍 3.13t • GIL @@ -360,9 +360,10 @@ jobs: container_suffix: "-bookworm" - 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: @@ -378,6 +379,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 @@ -521,11 +523,11 @@ jobs: - { gcc: 9, std: 20 } - { gcc: 10, std: 17 } - { gcc: 10, std: 20 } - - { gcc: 11, std: 20 } + - { gcc: 11, std: 20, cxx_flags: "-Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls" } - { gcc: 12, 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: @@ -547,6 +549,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 1ed2e90c2c..b26e76f6cf 100644 --- a/include/pybind11/detail/class.h +++ b/include/pybind11/detail/class.h @@ -497,8 +497,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/gil.h b/include/pybind11/gil.h index 888810493c..255eaa9438 100644 --- a/include/pybind11/gil.h +++ b/include/pybind11/gil.h @@ -21,9 +21,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) #if !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 315a5bad04..e5e333a846 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -344,7 +344,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}