diff --git a/include/pybind11/attr.h b/include/pybind11/attr.h index 97147904c..60ed9fd90 100644 --- a/include/pybind11/attr.h +++ b/include/pybind11/attr.h @@ -62,7 +62,8 @@ struct metaclass { handle value; PYBIND11_DEPRECATED("py::metaclass() is no longer required. It's turned on by default now.") - metaclass() { } // NOLINT(modernize-use-equals-default): breaks MSVC 2015 when adding an attribute + // NOLINTNEXTLINE(modernize-use-equals-default): breaks MSVC 2015 when adding an attribute + metaclass() {} /// Override pybind11's default metaclass explicit metaclass(handle value) : value(value) { } diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 1f7446103..f804e7c85 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -801,7 +801,8 @@ struct nodelete { template void operator()(T*) { } }; PYBIND11_NAMESPACE_BEGIN(detail) template struct overload_cast_impl { - constexpr overload_cast_impl() {}; // NOLINT(modernize-use-equals-default): MSVC 2015 needs this + // NOLINTNEXTLINE(modernize-use-equals-default): MSVC 2015 needs this + constexpr overload_cast_impl() {} template constexpr auto operator()(Return (*pf)(Args...)) const noexcept diff --git a/tests/pybind11_tests.h b/tests/pybind11_tests.h index ccb052978..d970ba8bd 100644 --- a/tests/pybind11_tests.h +++ b/tests/pybind11_tests.h @@ -1,10 +1,15 @@ #pragma once + +// This must be kept first for MSVC 2015. +// Do not remove the empty line between the #includes. #include + #include #if defined(_MSC_VER) && _MSC_VER < 1910 // We get some really long type names here which causes MSVC 2015 to emit warnings -# pragma warning(disable: 4503) // warning C4503: decorated name length exceeded, name was truncated +# pragma warning( \ + disable : 4503) // warning C4503: decorated name length exceeded, name was truncated #endif namespace py = pybind11; diff --git a/tests/test_buffers.cpp b/tests/test_buffers.cpp index 15dd4f1c7..e77c626f8 100644 --- a/tests/test_buffers.cpp +++ b/tests/test_buffers.cpp @@ -154,7 +154,7 @@ TEST_SUBMODULE(buffers, m) { py::format_descriptor::format(), 1); } - ConstBuffer() : value(new int32_t{0}) { }; + ConstBuffer() : value(new int32_t{0}) {} }; py::class_(m, "ConstBuffer", py::buffer_protocol()) .def(py::init<>()) diff --git a/tests/test_callbacks.cpp b/tests/test_callbacks.cpp index 7e79217a3..a208b44d0 100644 --- a/tests/test_callbacks.cpp +++ b/tests/test_callbacks.cpp @@ -122,7 +122,7 @@ TEST_SUBMODULE(callbacks, m) { // [workaround(intel)] = default does not work here // Defaulting this destructor results in linking errors with the Intel compiler // (in Debug builds only, tested with icpc (ICC) 2021.1 Beta 20200827) - virtual ~AbstractBase() {}; // NOLINT(modernize-use-equals-default) + virtual ~AbstractBase() {} // NOLINT(modernize-use-equals-default) virtual unsigned int func() = 0; }; m.def("func_accepting_func_accepting_base", diff --git a/tests/test_eigen.cpp b/tests/test_eigen.cpp index ba74f5815..651be0575 100644 --- a/tests/test_eigen.cpp +++ b/tests/test_eigen.cpp @@ -258,7 +258,10 @@ TEST_SUBMODULE(eigen, m) { m.def("dense_copy_r", [](const DenseMatrixR &m) -> DenseMatrixR { return m; }); m.def("dense_copy_c", [](const DenseMatrixC &m) -> DenseMatrixC { return m; }); // test_sparse, test_sparse_signature - m.def("sparse_r", [mat]() -> SparseMatrixR { return Eigen::SparseView(mat); }); //NOLINT(clang-analyzer-core.uninitialized.UndefReturn) + m.def("sparse_r", [mat]() -> SparseMatrixR { + // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) + return Eigen::SparseView(mat); + }); m.def("sparse_c", [mat]() -> SparseMatrixC { return Eigen::SparseView(mat); }); m.def("sparse_copy_r", [](const SparseMatrixR &m) -> SparseMatrixR { return m; }); m.def("sparse_copy_c", [](const SparseMatrixC &m) -> SparseMatrixC { return m; }); diff --git a/tests/test_methods_and_attributes.cpp b/tests/test_methods_and_attributes.cpp index 6e5999f0c..9db31a0b8 100644 --- a/tests/test_methods_and_attributes.cpp +++ b/tests/test_methods_and_attributes.cpp @@ -123,7 +123,7 @@ class NoneCastTester { public: int answer = -1; NoneCastTester() = default; - NoneCastTester(int v) : answer(v) {}; + NoneCastTester(int v) : answer(v) {} }; struct StrIssue { @@ -390,14 +390,14 @@ TEST_SUBMODULE(methods_and_attributes, m) { .def("increase_value", &RegisteredDerived::increase_value) .def_readwrite("rw_value", &RegisteredDerived::rw_value) .def_readonly("ro_value", &RegisteredDerived::ro_value) - // These should trigger a static_assert if uncommented - //.def_readwrite("fails", &UserType::value) // should trigger a static_assert if uncommented - //.def_readonly("fails", &UserType::value) // should trigger a static_assert if uncommented + // Uncommenting the next line should trigger a static_assert: + // .def_readwrite("fails", &UserType::value) + // Uncommenting the next line should trigger a static_assert: + // .def_readonly("fails", &UserType::value) .def_property("rw_value_prop", &RegisteredDerived::get_int, &RegisteredDerived::set_int) .def_property_readonly("ro_value_prop", &RegisteredDerived::get_double) // This one is in the registered class: - .def("sum", &RegisteredDerived::sum) - ; + .def("sum", &RegisteredDerived::sum); using Adapted = decltype(py::method_adaptor(&RegisteredDerived::do_nothing)); static_assert(std::is_same::value, ""); diff --git a/tests/test_smart_ptr.cpp b/tests/test_smart_ptr.cpp index 534dec0be..7fd5a9b36 100644 --- a/tests/test_smart_ptr.cpp +++ b/tests/test_smart_ptr.cpp @@ -24,7 +24,7 @@ template class huge_unique_ptr { std::unique_ptr ptr; uint64_t padding[10]; public: - huge_unique_ptr(T *p) : ptr(p) {}; + huge_unique_ptr(T *p) : ptr(p) {} T *get() { return ptr.get(); } };