diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -67,8 +67,9 @@ ABI Changes in This Version --------------------------- -- A bug in evaluating the ineligibility of some special member functions has been fixed. This can - make some classes trivially copyable that were not trivially copyable before. (`#62555 `_) +- Two bug in evaluating the ineligibility of some special member functions has been fixed. This can + make some classes trivially copyable that were not trivially copyable before. + (`#62555 `_, `#63352 `_) What's New in Clang |release|? ============================== diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -1269,13 +1269,14 @@ /// (C++ [class.copy]p6, C++11 [class.copy]p12) bool hasNonTrivialCopyConstructor() const { return data().DeclaredNonTrivialSpecialMembers & SMF_CopyConstructor || - !hasTrivialCopyConstructor(); + (needsImplicitCopyConstructor() && !hasTrivialCopyConstructor()); } bool hasNonTrivialCopyConstructorForCall() const { return (data().DeclaredNonTrivialSpecialMembersForCall & SMF_CopyConstructor) || - !hasTrivialCopyConstructorForCall(); + (needsImplicitCopyConstructor() && + !hasTrivialCopyConstructorForCall()); } /// Determine whether this class has a trivial move constructor @@ -1315,7 +1316,7 @@ /// operator (C++ [class.copy]p11, C++11 [class.copy]p25) bool hasNonTrivialCopyAssignment() const { return data().DeclaredNonTrivialSpecialMembers & SMF_CopyAssignment || - !hasTrivialCopyAssignment(); + (needsImplicitCopyAssignment() && !hasTrivialCopyAssignment()); } /// Determine whether this class has a trivial move assignment operator diff --git a/clang/test/SemaCXX/constrained-special-member-functions.cpp b/clang/test/SemaCXX/constrained-special-member-functions.cpp --- a/clang/test/SemaCXX/constrained-special-member-functions.cpp +++ b/clang/test/SemaCXX/constrained-special-member-functions.cpp @@ -312,3 +312,16 @@ static_assert(__is_trivially_copyable(ExplicitTemplateArgs)); } + + +namespace GH63352 { +template class C1 { C1(const C1&) requires B; }; +template class C2 { C2(C2&&) requires B; }; +template class C3 { C3& operator=(const C3&) requires B; }; +template class C4 { C4& operator=(C4&&) requires B; }; + +static_assert(__is_trivially_copyable(C1)); +static_assert(__is_trivially_copyable(C2)); +static_assert(__is_trivially_copyable(C3)); +static_assert(__is_trivially_copyable(C4)); +}