Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaTypeTraits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ static void DiagnoseNonTriviallyRelocatableReason(Sema &SemaRef,
}

if (!D->hasSimpleMoveConstructor() && !D->hasSimpleCopyConstructor()) {
const auto *Decl = cast<CXXConstructorDecl>(
const auto *Decl = cast_or_null<CXXConstructorDecl>(
LookupSpecialMemberFromXValue(SemaRef, D, /*Assign=*/false));
if (Decl && Decl->isUserProvided())
SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
Expand Down
44 changes: 44 additions & 0 deletions clang/test/SemaCXX/type-traits-unsatisfied-diags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,50 @@ static_assert(__builtin_is_cpp_trivially_relocatable(U2));

}


namespace GH143325 {
struct Foo { // expected-note {{previous definition is here}}
Foo(const Foo&);
~Foo();
};

struct Foo { // expected-error {{redefinition of 'Foo'}}
Foo();
int;
};
struct Wrapper { // #GH143325-Wrapper
union {
Foo p;
} u;
};

static_assert(__builtin_is_cpp_trivially_relocatable(Wrapper));
// expected-error@-1 {{static assertion failed due to requirement '__builtin_is_cpp_trivially_relocatable(GH143325::Wrapper)'}} \
// expected-note@-1 {{'Wrapper' is not trivially relocatable}} \
// expected-note@-1 {{because it has a non-trivially-relocatable member 'u' of type 'union}} \
// expected-note@-1 {{because it has a deleted destructor}}
// expected-note@#GH143325-Wrapper {{'Wrapper' defined here}}

struct Polymorphic {
virtual ~Polymorphic();
};

struct UnionOfPolymorphic { // #GH143325-UnionOfPolymorphic
union {
Polymorphic p;
int i;
} u;
};

static_assert(__builtin_is_cpp_trivially_relocatable(UnionOfPolymorphic));
// expected-error@-1 {{static assertion failed due to requirement '__builtin_is_cpp_trivially_relocatable(GH143325::UnionOfPolymorphic)'}} \
// expected-note@-1 {{'UnionOfPolymorphic' is not trivially relocatable}} \
// expected-note@-1 {{because it has a non-trivially-relocatable member 'u' of type 'union}} \
// expected-note@-1 {{because it has a deleted destructor}} \
// expected-note@#GH143325-UnionOfPolymorphic {{'UnionOfPolymorphic' defined here}}

}

namespace trivially_copyable {
struct B {
virtual ~B();
Expand Down
Loading