Skip to content

Commit 8edd53d

Browse files
committed
Fixed check for trivial destructor using Dtr->isTrivial() now, removed union
1 parent 2e423a7 commit 8edd53d

File tree

2 files changed

+1
-47
lines changed

2 files changed

+1
-47
lines changed

clang/lib/Sema/SemaTypeTraits.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,23 +2112,6 @@ static void DiagnoseNonTriviallyCopyableReason(Sema &SemaRef,
21122112
<< diag::TraitNotSatisfiedReason::DeletedDtr << 0
21132113
<< D->getDestructor()->getSourceRange();
21142114

2115-
if (D->isUnion()) {
2116-
auto DiagSPM = [&](CXXSpecialMemberKind K, bool Has) {
2117-
if (Has)
2118-
SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
2119-
<< diag::TraitNotSatisfiedReason::UnionWithUserDeclaredSMF << K;
2120-
};
2121-
DiagSPM(CXXSpecialMemberKind::CopyConstructor,
2122-
D->hasUserDeclaredCopyConstructor());
2123-
DiagSPM(CXXSpecialMemberKind::CopyAssignment,
2124-
D->hasUserDeclaredCopyAssignment());
2125-
DiagSPM(CXXSpecialMemberKind::MoveConstructor,
2126-
D->hasUserDeclaredMoveConstructor());
2127-
DiagSPM(CXXSpecialMemberKind::MoveAssignment,
2128-
D->hasUserDeclaredMoveAssignment());
2129-
return;
2130-
}
2131-
21322115
if (!D->hasSimpleMoveConstructor() && !D->hasSimpleCopyConstructor()) {
21332116
const auto *Decl = cast<CXXConstructorDecl>(
21342117
LookupSpecialMemberFromXValue(SemaRef, D, /*Assign=*/false));
@@ -2146,7 +2129,7 @@ static void DiagnoseNonTriviallyCopyableReason(Sema &SemaRef,
21462129
<< Decl->isMoveAssignmentOperator() << Decl->getSourceRange();
21472130
}
21482131
CXXDestructorDecl *Dtr = D->getDestructor();
2149-
if (Dtr && Dtr->isUserProvided() && !Dtr->isDefaulted())
2132+
if (Dtr && !Dtr->isTrivial())
21502133
SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
21512134
<< diag::TraitNotSatisfiedReason::DeletedDtr << 1
21522135
<< Dtr->getSourceRange();

clang/test/SemaCXX/type-traits-unsatisfied-diags.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,6 @@ struct S3 {
184184
};
185185
static_assert(__is_trivially_copyable(S3));
186186

187-
union U { // #tc-U
188-
U(const U&);
189-
U(U&&);
190-
U& operator=(const U&);
191-
U& operator=(U&&);
192-
};
193-
static_assert(__is_trivially_copyable(U));
194-
// expected-error@-1 {{static assertion failed due to requirement '__is_trivially_copyable(trivially_copyable::U)'}} \
195-
// expected-note@-1 {{'U' is not trivially copyable}} \
196-
// expected-note@-1 {{because it is a union with a user-declared copy constructor}} \
197-
// expected-note@-1 {{because it is a union with a user-declared copy assignment operator}} \
198-
// expected-note@-1 {{because it is a union with a user-declared move constructor}} \
199-
// expected-note@-1 {{because it is a union with a user-declared move assignment operator}}
200-
// expected-note@#tc-U {{'U' defined here}}
201-
202187
struct S4 { // #tc-S4
203188
~S4();
204189
B b;
@@ -209,18 +194,4 @@ static_assert(__is_trivially_copyable(S4));
209194
// expected-note@-1 {{because it has a non-trivially-copyable member 'b' of type 'B'}} \
210195
// expected-note@-1 {{because it has a user-provided destructor}} \
211196
// expected-note@#tc-S4 {{'S4' defined here}}
212-
213-
union U2 { // #tc-U2
214-
U2(const U2&);
215-
U2(U2&&);
216-
B b;
217-
};
218-
static_assert(__is_trivially_copyable(U2));
219-
// expected-error@-1 {{static assertion failed due to requirement '__is_trivially_copyable(trivially_copyable::U2)'}} \
220-
// expected-note@-1 {{'U2' is not trivially copyable}} \
221-
// expected-note@-1 {{because it is a union with a user-declared copy constructor}} \
222-
// expected-note@-1 {{because it is a union with a user-declared move constructor}} \
223-
// expected-note@-1 {{because it has a deleted destructor}} \
224-
// expected-note@-1 {{because it has a non-trivially-copyable member 'b' of type 'B'}} \
225-
// expected-note@#tc-U2 {{'U2' defined here}}
226197
}

0 commit comments

Comments
 (0)