@@ -769,6 +769,8 @@ TEST(TriviallyRelocatable, UserProvidedDestructor) {
769769// __is_trivially_relocatable is used there again.
770770// TODO(b/324278148): remove the opt-out for Apple once
771771// __is_trivially_relocatable is fixed there.
772+ // TODO(b/325479096): remove the opt-out for Clang once
773+ // __is_trivially_relocatable is fixed there.
772774#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) && \
773775 ABSL_HAVE_BUILTIN (__is_trivially_relocatable) && \
774776 (defined (__cpp_impl_trivially_relocatable) || \
@@ -779,8 +781,28 @@ TEST(TriviallyRelocatable, TrivialAbi) {
779781 struct ABSL_ATTRIBUTE_TRIVIAL_ABI S {
780782 S (S&&) {} // NOLINT(modernize-use-equals-default)
781783 S (const S&) {} // NOLINT(modernize-use-equals-default)
782- void operator =(S&&) {}
783- void operator =(const S&) {}
784+ S& operator =(S&&) { return *this ; }
785+ S& operator =(const S&) { return *this ; }
786+ ~S () {} // NOLINT(modernize-use-equals-default)
787+ };
788+
789+ static_assert (absl::is_trivially_relocatable<S>::value, " " );
790+ }
791+ #endif
792+
793+ // TODO(b/275003464): remove the opt-out for Clang on Windows once
794+ // __is_trivially_relocatable is used there again.
795+ // TODO(b/324278148): remove the opt-out for Apple once
796+ // __is_trivially_relocatable is fixed there.
797+ #if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) && \
798+ ABSL_HAVE_BUILTIN (__is_trivially_relocatable) && defined(__clang__) && \
799+ !(defined (_WIN32) || defined(_WIN64)) && !defined(__APPLE__) && \
800+ !defined(__NVCC__)
801+ // A type marked with the "trivial ABI" attribute is trivially relocatable even
802+ // if it has a user-provided copy constructor and a user-provided destructor.
803+ TEST(TriviallyRelocatable, TrivialAbi_NoUserProvidedMove) {
804+ struct ABSL_ATTRIBUTE_TRIVIAL_ABI S {
805+ S (const S&) {} // NOLINT(modernize-use-equals-default)
784806 ~S () {} // NOLINT(modernize-use-equals-default)
785807 };
786808
0 commit comments