From 4f002f1e236c1a0e7bdb096cd845f1a9c6c129c6 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Thu, 16 Apr 2020 16:34:13 -0400 Subject: VariadicMatcher needs a non-defaulted move constructor for compile-time performance. We are about to remove all uses of GTEST_DISALLOW_ASSIGN_ in favor of using the Rule of Zero everywhere. Unfortunately, if we use the Rule of Zero here, then when the compiler needs to figure out if VariadicMatcher is move-constructible, it will recurse down into `tuple`, which on libstdc++ recurses too deeply. In file included from googlemock/test/gmock-matchers_test.cc:43: In file included from googlemock/include/gmock/gmock-matchers.h:258: In file included from /usr/include/c++/5.5.0/algorithm:60: In file included from /usr/include/c++/5.5.0/utility:70: In file included from /usr/include/c++/5.5.0/bits/stl_pair.h:59: In file included from /usr/include/c++/5.5.0/bits/move.h:57: /usr/bin/include/c++/5.5.0/type_traits:115:26: fatal error: recursive template instantiation exceeded maximum depth of 256 : public conditional<_B1::value, _B1, _B2>::type ^ The move constructor is the only problematic case, for some unknown reason. With GTEST_DISALLOW_ASSIGN_, the presence of a copy assignment operator causes the move constructor to be non-declared, thus non-defaulted, thus non-problematic. Without GTEST_DISALLOW_ASSIGN_, we have to do one of the following: - Default the copy constructor, so that the move constructor will be non-declared. - Define our own non-defaulted move constructor. ...except that doing the latter STILL did not work! Fortunately, the former (default the copy constructor, don't provide any move constructor) both works in practice and is semantically equivalent to the old code. --- googlemock/include/gmock/gmock-matchers.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index fe88a7c7..b5b662d4 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -1333,6 +1333,9 @@ class VariadicMatcher { static_assert(sizeof...(Args) > 0, "Must have at least one matcher."); } + VariadicMatcher(const VariadicMatcher&) = default; + VariadicMatcher& operator=(const VariadicMatcher&) = delete; + // This template type conversion operator allows an // VariadicMatcher object to match any type that // all of the provided matchers (Matcher1, Matcher2, ...) can match. @@ -1357,8 +1360,6 @@ class VariadicMatcher { std::integral_constant) const {} std::tuple matchers_; - - GTEST_DISALLOW_ASSIGN_(VariadicMatcher); }; template -- cgit v1.2.3 From 766ac2e1a413e87d42d67e3286c70f0af4853679 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Thu, 16 Apr 2020 15:52:17 -0400 Subject: Remove all uses of GTEST_DISALLOW_{MOVE_,}ASSIGN_. None of these are strictly needed for correctness. A large number of them (maybe all of them?) trigger `-Wdeprecated` warnings on Clang trunk as soon as you try to use the implicitly defaulted (but deprecated) copy constructor of a class that has deleted its copy assignment operator. By declaring a deleted copy assignment operator, the old code also caused the move constructor and move assignment operator to be non-declared. This means that the old code never got move semantics -- "move-construction" would simply call the defaulted (but deprecated) copy constructor instead. With the new code, "move-construction" calls the defaulted move constructor, which I believe is what we want to happen. So this is a runtime performance optimization. Unfortunately we can't yet physically remove the definitions of these macros from gtest-port.h, because they are being used by other code internally at Google (according to zhangxy988). But no new uses should be added going forward. --- googlemock/include/gmock/gmock-actions.h | 36 -------- googlemock/include/gmock/gmock-generated-actions.h | 4 - .../include/gmock/gmock-generated-actions.h.pump | 4 - googlemock/include/gmock/gmock-matchers.h | 96 ---------------------- googlemock/include/gmock/gmock-spec-builders.h | 4 - googlemock/src/gmock-matchers.cc | 2 - googlemock/test/gmock-actions_test.cc | 2 - googlemock/test/gmock-matchers_test.cc | 6 -- googletest/include/gtest/internal/gtest-internal.h | 2 - googletest/include/gtest/internal/gtest-port.h | 6 +- googletest/test/googletest-port-test.cc | 2 - 11 files changed, 2 insertions(+), 162 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 615651b3..58089e3c 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -570,13 +570,9 @@ class PolymorphicAction { private: Impl impl_; - - GTEST_DISALLOW_ASSIGN_(MonomorphicImpl); }; Impl impl_; - - GTEST_DISALLOW_ASSIGN_(PolymorphicAction); }; // Creates an Action from its implementation and returns it. The @@ -717,13 +713,9 @@ class ReturnAction { private: bool performed_; const std::shared_ptr wrapper_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; const std::shared_ptr value_; - - GTEST_DISALLOW_ASSIGN_(ReturnAction); }; // Implements the ReturnNull() action. @@ -784,13 +776,9 @@ class ReturnRefAction { private: T& ref_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; T& ref_; - - GTEST_DISALLOW_ASSIGN_(ReturnRefAction); }; // Implements the polymorphic ReturnRefOfCopy(x) action, which can be @@ -831,13 +819,9 @@ class ReturnRefOfCopyAction { private: T value_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; const T value_; - - GTEST_DISALLOW_ASSIGN_(ReturnRefOfCopyAction); }; // Implements the polymorphic ReturnRoundRobin(v) action, which can be @@ -894,8 +878,6 @@ class AssignAction { private: T1* const ptr_; const T2 value_; - - GTEST_DISALLOW_ASSIGN_(AssignAction); }; #if !GTEST_OS_WINDOWS_MOBILE @@ -917,8 +899,6 @@ class SetErrnoAndReturnAction { private: const int errno_; const T result_; - - GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction); }; #endif // !GTEST_OS_WINDOWS_MOBILE @@ -1024,13 +1004,9 @@ class IgnoreResultAction { OriginalFunction; const Action action_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; const A action_; - - GTEST_DISALLOW_ASSIGN_(IgnoreResultAction); }; template @@ -1467,13 +1443,7 @@ auto InvokeArgumentAdl(AdlTag, F f, Args... args) -> decltype(f(args...)) { template \ return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \ GMOCK_ACTION_FIELD_PARAMS_(params) \ - \ - private: \ - GTEST_DISALLOW_ASSIGN_(gmock_Impl); \ }; \ - \ - private: \ - GTEST_DISALLOW_ASSIGN_(full_name); \ }; \ template \ inline full_name name( \ @@ -1512,13 +1482,7 @@ auto InvokeArgumentAdl(AdlTag, F f, Args... args) -> decltype(f(args...)) { } \ template \ return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \ - \ - private: \ - GTEST_DISALLOW_ASSIGN_(gmock_Impl); \ }; \ - \ - private: \ - GTEST_DISALLOW_ASSIGN_(name##Action); \ }; \ inline name##Action name() { return name##Action(); } \ template \ diff --git a/googlemock/include/gmock/gmock-generated-actions.h b/googlemock/include/gmock/gmock-generated-actions.h index c78debef..0fe6acbc 100644 --- a/googlemock/include/gmock/gmock-generated-actions.h +++ b/googlemock/include/gmock/gmock-generated-actions.h @@ -435,16 +435,12 @@ template \ return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const;\ GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ };\ template operator ::testing::Action() const {\ return ::testing::Action(\ new gmock_Impl(GMOCK_INTERNAL_LIST_##value_params));\ }\ GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\ };\ template \ diff --git a/googlemock/include/gmock/gmock-generated-actions.h.pump b/googlemock/include/gmock/gmock-generated-actions.h.pump index be9d99fe..02fd9ff7 100644 --- a/googlemock/include/gmock/gmock-generated-actions.h.pump +++ b/googlemock/include/gmock/gmock-generated-actions.h.pump @@ -253,16 +253,12 @@ $range k 0..n-1 template \ return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const;\ GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ };\ template operator ::testing::Action() const {\ return ::testing::Action(\ new gmock_Impl(GMOCK_INTERNAL_LIST_##value_params));\ }\ GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\ };\ template \ diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index b5b662d4..c474e0b9 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -444,8 +444,6 @@ class MatcherCastImpl > { private: const Matcher source_matcher_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; }; @@ -861,13 +859,9 @@ class RefMatcher { private: const Super& object_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; T& object_; - - GTEST_DISALLOW_ASSIGN_(RefMatcher); }; // Polymorphic helper functions for narrow and wide string matchers. @@ -970,8 +964,6 @@ class StrEqualityMatcher { const StringType string_; const bool expect_eq_; const bool case_sensitive_; - - GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher); }; // Implements the polymorphic HasSubstr(substring) matcher, which @@ -1026,8 +1018,6 @@ class HasSubstrMatcher { private: const StringType substring_; - - GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher); }; // Implements the polymorphic StartsWith(substring) matcher, which @@ -1083,8 +1073,6 @@ class StartsWithMatcher { private: const StringType prefix_; - - GTEST_DISALLOW_ASSIGN_(StartsWithMatcher); }; // Implements the polymorphic EndsWith(substring) matcher, which @@ -1139,8 +1127,6 @@ class EndsWithMatcher { private: const StringType suffix_; - - GTEST_DISALLOW_ASSIGN_(EndsWithMatcher); }; // Implements a matcher that compares the two fields of a 2-tuple @@ -1234,8 +1220,6 @@ class NotMatcherImpl : public MatcherInterface { private: const Matcher matcher_; - - GTEST_DISALLOW_ASSIGN_(NotMatcherImpl); }; // Implements the Not(m) matcher, which matches a value that doesn't @@ -1254,8 +1238,6 @@ class NotMatcher { private: InnerMatcher matcher_; - - GTEST_DISALLOW_ASSIGN_(NotMatcher); }; // Implements the AllOf(m1, m2) matcher for a particular argument type @@ -1317,8 +1299,6 @@ class AllOfMatcherImpl : public MatcherInterface { private: const std::vector > matchers_; - - GTEST_DISALLOW_ASSIGN_(AllOfMatcherImpl); }; // VariadicMatcher is used for the variadic implementation of @@ -1424,8 +1404,6 @@ class AnyOfMatcherImpl : public MatcherInterface { private: const std::vector > matchers_; - - GTEST_DISALLOW_ASSIGN_(AnyOfMatcherImpl); }; // AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...). @@ -1453,8 +1431,6 @@ class SomeOfArrayMatcher { private: const ::std::vector matchers_; - - GTEST_DISALLOW_ASSIGN_(SomeOfArrayMatcher); }; template @@ -1498,8 +1474,6 @@ class TrulyMatcher { private: Predicate predicate_; - - GTEST_DISALLOW_ASSIGN_(TrulyMatcher); }; // Used for implementing Matches(matcher), which turns a matcher into @@ -1536,8 +1510,6 @@ class MatcherAsPredicate { private: M matcher_; - - GTEST_DISALLOW_ASSIGN_(MatcherAsPredicate); }; // For implementing ASSERT_THAT() and EXPECT_THAT(). The template @@ -1588,8 +1560,6 @@ class PredicateFormatterFromMatcher { private: const M matcher_; - - GTEST_DISALLOW_ASSIGN_(PredicateFormatterFromMatcher); }; // A helper function for converting a matcher to a predicate-formatter @@ -1741,8 +1711,6 @@ class FloatingEqMatcher { const bool nan_eq_nan_; // max_abs_error will be used for value comparison when >= 0. const FloatType max_abs_error_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; // The following 3 type conversion operators allow FloatEq(expected) and @@ -1771,8 +1739,6 @@ class FloatingEqMatcher { const bool nan_eq_nan_; // max_abs_error will be used for value comparison when >= 0. const FloatType max_abs_error_; - - GTEST_DISALLOW_ASSIGN_(FloatingEqMatcher); }; // A 2-tuple ("binary") wrapper around FloatingEqMatcher: @@ -1902,13 +1868,9 @@ class PointeeMatcher { private: const Matcher matcher_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; const InnerMatcher matcher_; - - GTEST_DISALLOW_ASSIGN_(PointeeMatcher); }; #if GTEST_HAS_RTTI @@ -1945,8 +1907,6 @@ class WhenDynamicCastToMatcherBase { static void GetCastTypeDescription(::std::ostream* os) { *os << "when dynamic_cast to " << GetToName() << ", "; } - - GTEST_DISALLOW_ASSIGN_(WhenDynamicCastToMatcherBase); }; // Primary template. @@ -2044,8 +2004,6 @@ class FieldMatcher { // Contains either "whose given field " if the name of the field is unknown // or "whose field `name_of_field` " if the name is known. const std::string whose_field_; - - GTEST_DISALLOW_ASSIGN_(FieldMatcher); }; // Implements the Property() matcher for matching a property @@ -2114,8 +2072,6 @@ class PropertyMatcher { // Contains either "whose given property " if the name of the property is // unknown or "whose property `name_of_property` " if the name is known. const std::string whose_property_; - - GTEST_DISALLOW_ASSIGN_(PropertyMatcher); }; // Type traits specifying various features of different functors for ResultOf. @@ -2205,14 +2161,10 @@ class ResultOfMatcher { // how many times the callable will be invoked. mutable CallableStorageType callable_; const Matcher matcher_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; // class Impl const CallableStorageType callable_; const InnerMatcher matcher_; - - GTEST_DISALLOW_ASSIGN_(ResultOfMatcher); }; // Implements a matcher that checks the size of an STL-style container. @@ -2257,12 +2209,10 @@ class SizeIsMatcher { private: const Matcher size_matcher_; - GTEST_DISALLOW_ASSIGN_(Impl); }; private: const SizeMatcher size_matcher_; - GTEST_DISALLOW_ASSIGN_(SizeIsMatcher); }; // Implements a matcher that checks the begin()..end() distance of an STL-style @@ -2314,12 +2264,10 @@ class BeginEndDistanceIsMatcher { private: const Matcher distance_matcher_; - GTEST_DISALLOW_ASSIGN_(Impl); }; private: const DistanceMatcher distance_matcher_; - GTEST_DISALLOW_ASSIGN_(BeginEndDistanceIsMatcher); }; // Implements an equality matcher for any STL-style container whose elements @@ -2412,8 +2360,6 @@ class ContainerEqMatcher { private: const StlContainer expected_; - - GTEST_DISALLOW_ASSIGN_(ContainerEqMatcher); }; // A comparator functor that uses the < operator to compare two values. @@ -2495,8 +2441,6 @@ class WhenSortedByMatcher { private: const Comparator comparator_; const ContainerMatcher matcher_; - - GTEST_DISALLOW_ASSIGN_(WhenSortedByMatcher); }; // Implements Pointwise(tuple_matcher, rhs_container). tuple_matcher @@ -2612,15 +2556,11 @@ class PointwiseMatcher { private: const Matcher mono_tuple_matcher_; const RhsStlContainer rhs_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; private: const TupleMatcher tuple_matcher_; const RhsStlContainer rhs_; - - GTEST_DISALLOW_ASSIGN_(PointwiseMatcher); }; // Holds the logic common to ContainsMatcherImpl and EachMatcherImpl. @@ -2663,8 +2603,6 @@ class QuantifierMatcherImpl : public MatcherInterface { protected: const Matcher inner_matcher_; - - GTEST_DISALLOW_ASSIGN_(QuantifierMatcherImpl); }; // Implements Contains(element_matcher) for the given argument type Container. @@ -2691,9 +2629,6 @@ class ContainsMatcherImpl : public QuantifierMatcherImpl { MatchResultListener* listener) const override { return this->MatchAndExplainImpl(false, container, listener); } - - private: - GTEST_DISALLOW_ASSIGN_(ContainsMatcherImpl); }; // Implements Each(element_matcher) for the given argument type Container. @@ -2720,9 +2655,6 @@ class EachMatcherImpl : public QuantifierMatcherImpl { MatchResultListener* listener) const override { return this->MatchAndExplainImpl(true, container, listener); } - - private: - GTEST_DISALLOW_ASSIGN_(EachMatcherImpl); }; // Implements polymorphic Contains(element_matcher). @@ -2739,8 +2671,6 @@ class ContainsMatcher { private: const M inner_matcher_; - - GTEST_DISALLOW_ASSIGN_(ContainsMatcher); }; // Implements polymorphic Each(element_matcher). @@ -2757,8 +2687,6 @@ class EachMatcher { private: const M inner_matcher_; - - GTEST_DISALLOW_ASSIGN_(EachMatcher); }; struct Rank1 {}; @@ -2829,8 +2757,6 @@ class KeyMatcherImpl : public MatcherInterface { private: const Matcher inner_matcher_; - - GTEST_DISALLOW_ASSIGN_(KeyMatcherImpl); }; // Implements polymorphic Key(matcher_for_key). @@ -2847,8 +2773,6 @@ class KeyMatcher { private: const M matcher_for_key_; - - GTEST_DISALLOW_ASSIGN_(KeyMatcher); }; // Implements Pair(first_matcher, second_matcher) for the given argument pair @@ -2934,8 +2858,6 @@ class PairMatcherImpl : public MatcherInterface { const Matcher first_matcher_; const Matcher second_matcher_; - - GTEST_DISALLOW_ASSIGN_(PairMatcherImpl); }; // Implements polymorphic Pair(first_matcher, second_matcher). @@ -2954,8 +2876,6 @@ class PairMatcher { private: const FirstMatcher first_matcher_; const SecondMatcher second_matcher_; - - GTEST_DISALLOW_ASSIGN_(PairMatcher); }; // Implements ElementsAre() and ElementsAreArray(). @@ -3101,8 +3021,6 @@ class ElementsAreMatcherImpl : public MatcherInterface { size_t count() const { return matchers_.size(); } ::std::vector > matchers_; - - GTEST_DISALLOW_ASSIGN_(ElementsAreMatcherImpl); }; // Connectivity matrix of (elements X matchers), in element-major order. @@ -3205,8 +3123,6 @@ class GTEST_API_ UnorderedElementsAreMatcherImplBase { private: UnorderedMatcherRequire::Flags match_flags_; MatcherDescriberVec matcher_describers_; - - GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcherImplBase); }; // Implements UnorderedElementsAre, UnorderedElementsAreArray, IsSubsetOf, and @@ -3302,8 +3218,6 @@ class UnorderedElementsAreMatcherImpl } ::std::vector > matchers_; - - GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcherImpl); }; // Functor for use in TransformTuple. @@ -3341,7 +3255,6 @@ class UnorderedElementsAreMatcher { private: const MatcherTuple matchers_; - GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcher); }; // Implements ElementsAre. @@ -3371,7 +3284,6 @@ class ElementsAreMatcher { private: const MatcherTuple matchers_; - GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher); }; // Implements UnorderedElementsAreArray(), IsSubsetOf(), and IsSupersetOf(). @@ -3393,8 +3305,6 @@ class UnorderedElementsAreArrayMatcher { private: UnorderedMatcherRequire::Flags match_flags_; ::std::vector matchers_; - - GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreArrayMatcher); }; // Implements ElementsAreArray(). @@ -3416,8 +3326,6 @@ class ElementsAreArrayMatcher { private: const ::std::vector matchers_; - - GTEST_DISALLOW_ASSIGN_(ElementsAreArrayMatcher); }; // Given a 2-tuple matcher tm of type Tuple2Matcher and a value second @@ -3479,8 +3387,6 @@ class BoundSecondMatcher { private: const Matcher mono_tuple2_matcher_; const Second second_value_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; const Tuple2Matcher tuple2_matcher_; @@ -3553,12 +3459,10 @@ class OptionalMatcher { private: const Matcher value_matcher_; - GTEST_DISALLOW_ASSIGN_(Impl); }; private: const ValueMatcher value_matcher_; - GTEST_DISALLOW_ASSIGN_(OptionalMatcher); }; namespace variant_matcher { diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 4b5fc661..2baec446 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -879,8 +879,6 @@ class GTEST_API_ ExpectationBase { Clause last_clause_; mutable bool action_count_checked_; // Under mutex_. mutable Mutex mutex_; // Protects action_count_checked_. - - GTEST_DISALLOW_ASSIGN_(ExpectationBase); }; // class ExpectationBase // Impements an expectation for the given function type. @@ -1295,8 +1293,6 @@ class MockSpec { internal::FunctionMocker* const function_mocker_; // The argument matchers specified in the spec. ArgumentMatcherTuple matchers_; - - GTEST_DISALLOW_ASSIGN_(MockSpec); }; // class MockSpec // Wrapper type for generically holding an ordinary value or lvalue reference. diff --git a/googlemock/src/gmock-matchers.cc b/googlemock/src/gmock-matchers.cc index 4f73e0a6..dded437a 100644 --- a/googlemock/src/gmock-matchers.cc +++ b/googlemock/src/gmock-matchers.cc @@ -218,8 +218,6 @@ class MaxBipartiteMatchState { // right_[left_[i]] = i. ::std::vector left_; ::std::vector right_; - - GTEST_DISALLOW_ASSIGN_(MaxBipartiteMatchState); }; const size_t MaxBipartiteMatchState::kUnused; diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index d1229ac9..a252825a 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -575,8 +575,6 @@ class FromType { private: bool* const converted_; - - GTEST_DISALLOW_ASSIGN_(FromType); }; class ToType { diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 186d8aae..5db0a7ae 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -3746,17 +3746,11 @@ struct AStruct { const double y; // A const field. Uncopyable z; // An uncopyable field. const char* p; // A pointer field. - - private: - GTEST_DISALLOW_ASSIGN_(AStruct); }; // A derived struct for testing Field(). struct DerivedStruct : public AStruct { char ch; - - private: - GTEST_DISALLOW_ASSIGN_(DerivedStruct); }; // Tests that Field(&Foo::field, ...) works when field is non-const. diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 7f1a5b00..fabc8042 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -1120,8 +1120,6 @@ class NativeArray { const Element* array_; size_t size_; void (NativeArray::*clone_)(const Element*, size_t); - - GTEST_DISALLOW_ASSIGN_(NativeArray); }; // Backport of std::index_sequence. diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 21fcf822..44307a13 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -682,7 +682,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \ type(type const &) = delete; \ - GTEST_DISALLOW_ASSIGN_(type) + type& operator=(type const &) = delete // A macro to disallow move operator= // This should be used in the private: declarations for a class. @@ -693,7 +693,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_MOVE_AND_ASSIGN_(type) \ type(type &&) noexcept = delete; \ - GTEST_DISALLOW_MOVE_ASSIGN_(type) + type& operator=(type &&) noexcept = delete // Tell the compiler to warn about unused return values for functions declared // with this macro. The macro should be used on function declarations @@ -920,8 +920,6 @@ class GTEST_API_ RE { const char* full_pattern_; // For FullMatch(); # endif - - GTEST_DISALLOW_ASSIGN_(RE); }; #endif // GTEST_USES_PCRE diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index 60d637c3..2af75c20 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -1180,8 +1180,6 @@ class DestructorTracker { return DestructorCall::List().size() - 1; } const size_t index_; - - GTEST_DISALLOW_ASSIGN_(DestructorTracker); }; typedef ThreadLocal* ThreadParam; -- cgit v1.2.3 From 11b3cec177b1b655148b8352096a3cff10be62d2 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Thu, 16 Apr 2020 15:58:34 -0400 Subject: Fix a -Wdeprecated warning. gmock-spec-builders.h:503:3: error: definition of implicit copy constructor for 'Expectation' is deprecated because it has a user-declared destructor [-Werror,-Wdeprecated] ~Expectation(); ^ --- googlemock/include/gmock/gmock-spec-builders.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 2baec446..ac215501 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -499,7 +499,10 @@ class GTEST_API_ Expectation { public: // Constructs a null object that doesn't reference any expectation. Expectation(); - + Expectation(Expectation&&) = default; + Expectation(const Expectation&) = default; + Expectation& operator=(Expectation&&) = default; + Expectation& operator=(const Expectation&) = default; ~Expectation(); // This single-argument ctor must not be explicit, in order to support the -- cgit v1.2.3 From 01c0ff5e23735ed6b2e71904cde69f57efeae499 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Thu, 16 Apr 2020 16:07:43 -0400 Subject: Fix a -Wdeprecated warning. googletest-port-test.cc:97:11: error: definition of implicit copy constructor for 'Base' is deprecated because it has a user-declared destructor [-Werror,-Wdeprecated] virtual ~Base() {} ^ --- googletest/test/googletest-port-test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index 2af75c20..44b99ce5 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -90,10 +90,10 @@ TEST(IsXDigitTest, ReturnsFalseForWideNonAscii) { class Base { public: - // Copy constructor and assignment operator do exactly what we need, so we - // use them. Base() : member_(0) {} explicit Base(int n) : member_(n) {} + Base(const Base&) = default; + Base& operator=(const Base&) = default; virtual ~Base() {} int member() { return member_; } -- cgit v1.2.3 From c7d8ec72cc4baedbe1c3b1b304119e7a8b1a9262 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Thu, 16 Apr 2020 16:15:10 -0400 Subject: Fix a -Wdeprecated warning. 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] void operator=(const NonDefaultConstructAssignString&); ^ --- googletest/test/googletest-param-test-test.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/googletest/test/googletest-param-test-test.cc b/googletest/test/googletest-param-test-test.cc index 6ba89654..2b26e95f 100644 --- a/googletest/test/googletest-param-test-test.cc +++ b/googletest/test/googletest-param-test-test.cc @@ -490,16 +490,15 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) { class NonDefaultConstructAssignString { public: NonDefaultConstructAssignString(const std::string& s) : str_(s) {} + NonDefaultConstructAssignString() = delete; + NonDefaultConstructAssignString(const NonDefaultConstructAssignString&) = default; + NonDefaultConstructAssignString& operator=(const NonDefaultConstructAssignString&) = delete; + ~NonDefaultConstructAssignString() = default; const std::string& str() const { return str_; } private: std::string str_; - - // Not default constructible - NonDefaultConstructAssignString(); - // Not assignable - void operator=(const NonDefaultConstructAssignString&); }; TEST(CombineTest, NonDefaultConstructAssign) { -- cgit v1.2.3 From 1b066f4edfd5f84beed1bb164bd3816a6d7158fe Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 28 Mar 2020 01:24:58 -0400 Subject: Add -Wdeprecated to the build configuration. --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 27c725c0..930f9944 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,16 +25,16 @@ matrix: script: ./ci/build-linux-bazel.sh - os: linux compiler: gcc - env: BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS=-std=c++11 + env: BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" - os: linux compiler: clang - env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON - os: osx compiler: gcc - env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp - os: osx compiler: clang - env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp # These are the install and build (script) phases for the most common entries in the matrix. They could be included # in each entry in the matrix, but that is just repetitive. -- cgit v1.2.3