@@ -769,6 +769,8 @@ TEST(TriviallyRelocatable, UserProvidedDestructor) {
769
769
// __is_trivially_relocatable is used there again.
770
770
// TODO(b/324278148): remove the opt-out for Apple once
771
771
// __is_trivially_relocatable is fixed there.
772
+ // TODO(b/325479096): remove the opt-out for Clang once
773
+ // __is_trivially_relocatable is fixed there.
772
774
#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) && \
773
775
ABSL_HAVE_BUILTIN (__is_trivially_relocatable) && \
774
776
(defined(__cpp_impl_trivially_relocatable) || \
@@ -779,8 +781,28 @@ TEST(TriviallyRelocatable, TrivialAbi) {
779
781
struct ABSL_ATTRIBUTE_TRIVIAL_ABI S {
780
782
S (S&&) {} // NOLINT(modernize-use-equals-default)
781
783
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)
784
806
~S () {} // NOLINT(modernize-use-equals-default)
785
807
};
786
808
0 commit comments