Add -Wdeprecated to test suite and fix associated warnings (#1191)
This commit turns on `-Wdeprecated` in the test suite and fixes several
associated deprecation warnings that show up as a result:
- in C++17 `static constexpr` members are implicitly inline; our
redeclaration (needed for C++11/14) is deprecated in C++17.
- various test suite classes have destructors and rely on implicit copy
constructors, but implicit copy constructor definitions when a
user-declared destructor is present was deprecated in C++11.
- Eigen also has various implicit copy constructors, so just disable
`-Wdeprecated` in `eigen.h`.
diff --git a/tests/test_class.cpp b/tests/test_class.cpp
index 927adf3..57db3ab 100644
--- a/tests/test_class.cpp
+++ b/tests/test_class.cpp
@@ -14,6 +14,9 @@
TEST_SUBMODULE(class_, m) {
// test_instance
struct NoConstructor {
+ NoConstructor() = default;
+ NoConstructor(const NoConstructor &) = default;
+ NoConstructor(NoConstructor &&) = default;
static NoConstructor *new_instance() {
auto *ptr = new NoConstructor();
print_created(ptr, "via new_instance");
@@ -82,7 +85,12 @@
m.def("dog_bark", [](const Dog &dog) { return dog.bark(); });
// test_automatic_upcasting
- struct BaseClass { virtual ~BaseClass() {} };
+ struct BaseClass {
+ BaseClass() = default;
+ BaseClass(const BaseClass &) = default;
+ BaseClass(BaseClass &&) = default;
+ virtual ~BaseClass() {}
+ };
struct DerivedClass1 : BaseClass { };
struct DerivedClass2 : BaseClass { };