@@ -7492,7 +7492,7 @@ hasSuitableMoveAssignmentOperatorForRelocation(Sema &SemaRef, CXXRecordDecl *D,
74927492// type C selects an assignment operator function that is a direct member of C
74937493// and is neither user-provided nor deleted, and C has a destructor that is
74947494// neither user-provided nor deleted.
7495- static bool isDefaultMovable(Sema &SemaRef, CXXRecordDecl *D) {
7495+ static bool isDefaultMovable(Sema &SemaRef, CXXRecordDecl *D, CXXDestructorDecl* Dtr ) {
74967496 if (!hasSuitableConstructorForRelocation(SemaRef, D,
74977497 /*AllowUserDefined=*/false))
74987498 return false;
@@ -7501,7 +7501,6 @@ static bool isDefaultMovable(Sema &SemaRef, CXXRecordDecl *D) {
75017501 SemaRef, D, /*AllowUserDefined=*/false))
75027502 return false;
75037503
7504- const auto *Dtr = D->getDestructor();
75057504 if (!Dtr)
75067505 return true;
75077506
@@ -7537,9 +7536,7 @@ static bool isEligibleForTrivialRelocation(Sema &SemaRef, CXXRecordDecl *D) {
75377536 SemaRef.getASTContext()))
75387537 return false;
75397538 }
7540-
7541- // ...has a deleted destructor
7542- return !D->hasDeletedDestructor();
7539+ return true;
75437540}
75447541
75457542// [C++26][class.prop]
@@ -7563,9 +7560,7 @@ static bool isEligibleForReplacement(Sema &SemaRef, CXXRecordDecl *D) {
75637560 if (!Field->getType().isReplaceableType(SemaRef.getASTContext()))
75647561 return false;
75657562 }
7566-
7567- // it has a deleted destructor.
7568- return !D->hasDeletedDestructor();
7563+ return true;
75697564}
75707565
75717566void Sema::CheckCXX2CRelocatableAndReplaceable(CXXRecordDecl *D) {
@@ -7577,6 +7572,7 @@ void Sema::CheckCXX2CRelocatableAndReplaceable(CXXRecordDecl *D) {
75777572 bool MarkedCXX2CReplaceable = D->hasAttr<ReplaceableAttr>();
75787573 bool MarkedTriviallyRelocatable = D->hasAttr<TriviallyRelocatableAttr>();
75797574
7575+
75807576 // This is part of "eligible for replacement", however we defer it
75817577 // to avoid extraneous computations.
75827578 auto HasSuitableSMP = [&] {
@@ -7595,9 +7591,15 @@ void Sema::CheckCXX2CRelocatableAndReplaceable(CXXRecordDecl *D) {
75957591 return *Is;
75967592 };
75977593
7594+ auto GetDestructor = [&, Dtr = static_cast<CXXDestructorDecl*>(nullptr)]() mutable {
7595+ if(!Dtr)
7596+ Dtr = D->getDestructor();
7597+ return Dtr;
7598+ };
7599+
75987600 auto IsDefaultMovable = [&, Is = std::optional<bool>{}]() mutable {
75997601 if (!Is.has_value())
7600- Is = isDefaultMovable(*this, D);
7602+ Is = isDefaultMovable(*this, D, GetDestructor() );
76017603 return *Is;
76027604 };
76037605
@@ -7609,6 +7611,9 @@ void Sema::CheckCXX2CRelocatableAndReplaceable(CXXRecordDecl *D) {
76097611 if (!isEligibleForTrivialRelocation(*this, D))
76107612 return false;
76117613
7614+ if(auto* Dtr = GetDestructor(); Dtr && Dtr->isDeleted())
7615+ return false;
7616+
76127617 // has the trivially_relocatable_if_eligible class-property-specifier,
76137618 if (MarkedTriviallyRelocatable)
76147619 return true;
@@ -7631,6 +7636,9 @@ void Sema::CheckCXX2CRelocatableAndReplaceable(CXXRecordDecl *D) {
76317636 if (!isEligibleForReplacement(*this, D))
76327637 return false;
76337638
7639+ if(auto* Dtr = GetDestructor(); Dtr && Dtr->isDeleted())
7640+ return false;
7641+
76347642 // has the replaceable_if_eligible class-property-specifier
76357643 if (MarkedCXX2CReplaceable)
76367644 return HasSuitableSMP();
0 commit comments