diff options
author | Abseil Team <absl-team@google.com> | 2020-04-20 19:03:58 -0400 |
---|---|---|
committer | Gennadiy Rozental <rogeeff@google.com> | 2020-05-01 17:11:08 -0400 |
commit | 1b3eb6ef34620c1203263d76ec169ef0853789cc (patch) | |
tree | 876871b2de86fc0b19965508ab269b23b70e58f2 | |
parent | fb5d9b66c5b09d7eed1e11aeeabfac4cf987f42c (diff) | |
download | googletest-1b3eb6ef34620c1203263d76ec169ef0853789cc.tar.gz googletest-1b3eb6ef34620c1203263d76ec169ef0853789cc.tar.bz2 googletest-1b3eb6ef34620c1203263d76ec169ef0853789cc.zip |
Googletest export
Explicitly define copy constructors used in googletest tests
As of C++11, providing a user-declared copy assignment operator should
suppress the availability of an implicit default copy constructor.
Classes that provide (or delete) a copy assignment operator must provide
their own copy constructor if one is desired. This may be an explicit
default copy constructor if appropriate.
As googletest is a C++11 codebase, this change should be made without
qualification.
This addresses the -Wdeprecated-copy warnings issued by trunk clang:
While compiling googletest/test/googletest-death-test-test.cc:
In file included from .../googletest/test/googletest-death-test-test.cc:33:
.../googletest/include/gtest/gtest-death-test.h:196:8: error: definition of implicit copy constructor for 'ExitedWithCode' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
void operator=(const ExitedWithCode& other);
^
.../googletest/test/googletest-death-test-test.cc:279:16: note: in implicit copy constructor for 'testing::ExitedWithCode' first required here
EXPECT_PRED1(pred0, status0);
^
While compiling googletest/test/googletest-param-test-test.cc:
.../googletest/test/googletest-param-test-test.cc:502:8: error: definition of implicit copy constructor for 'NonDefaultConstructAssignString' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
void operator=(const NonDefaultConstructAssignString&);
^
.../googletest/test/googletest-param-test-test.cc:507:36: note: in implicit copy constructor for 'NonDefaultConstructAssignString' first required here
Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"),
This matches other changes made elsewhere in the googletest codebase,
such as 306f3754a71d. Perhaps those previous changes did not consider
test code.
PiperOrigin-RevId: 307495126
-rw-r--r-- | googletest/include/gtest/gtest-death-test.h | 5 | ||||
-rw-r--r-- | googletest/test/googletest-param-test-test.cc | 10 |
2 files changed, 7 insertions, 8 deletions
diff --git a/googletest/include/gtest/gtest-death-test.h b/googletest/include/gtest/gtest-death-test.h index dc878ffb..2bd41cf3 100644 --- a/googletest/include/gtest/gtest-death-test.h +++ b/googletest/include/gtest/gtest-death-test.h @@ -190,11 +190,10 @@ GTEST_API_ bool InDeathTestChild(); class GTEST_API_ ExitedWithCode { public: explicit ExitedWithCode(int exit_code); + ExitedWithCode(const ExitedWithCode&) = default; + void operator=(const ExitedWithCode& other) = delete; bool operator()(int exit_status) const; private: - // No implementation - assignment is unsupported. - void operator=(const ExitedWithCode& other); - const int exit_code_; }; diff --git a/googletest/test/googletest-param-test-test.cc b/googletest/test/googletest-param-test-test.cc index 6ba89654..0ab0d6f3 100644 --- a/googletest/test/googletest-param-test-test.cc +++ b/googletest/test/googletest-param-test-test.cc @@ -490,16 +490,16 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) { class NonDefaultConstructAssignString { public: NonDefaultConstructAssignString(const std::string& s) : str_(s) {} + NonDefaultConstructAssignString(const NonDefaultConstructAssignString&) = + default; + + NonDefaultConstructAssignString() = delete; + void operator=(const NonDefaultConstructAssignString&) = delete; const std::string& str() const { return str_; } private: std::string str_; - - // Not default constructible - NonDefaultConstructAssignString(); - // Not assignable - void operator=(const NonDefaultConstructAssignString&); }; TEST(CombineTest, NonDefaultConstructAssign) { |