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
5 changes: 3 additions & 2 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3112,11 +3112,12 @@ namespace {
}
}
}
if (copyCtor && !isExplicitlyNonCopyable) {
if (copyCtor && !isExplicitlyNonCopyable &&
!decl->isAnonymousStructOrUnion()) {
clangSema.DefineImplicitCopyConstructor(clang::SourceLocation(),
copyCtor);
}
if (moveCtor) {
if (moveCtor && !decl->isAnonymousStructOrUnion()) {
clangSema.DefineImplicitMoveConstructor(clang::SourceLocation(),
moveCtor);
}
Expand Down
4 changes: 4 additions & 0 deletions lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6940,6 +6940,10 @@ namespace {
}

void addValueWitnessTable() {
if (auto cd = Target->getClangDecl())
if (auto rd = dyn_cast<clang::RecordDecl>(cd))
if (rd->isAnonymousStructOrUnion())
return;
auto vwtPointer = emitValueWitnessTable(/*relative*/ false).getValue();
B.addSignedPointer(vwtPointer,
IGM.getOptions().PointerAuth.ValueWitnessTable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,16 @@ struct NonCopyableHolderDerivedDerived: NonCopyableHolderDerived {
inline NonCopyable *getNonCopyablePtr() { return nullptr; }
inline NonCopyableDerived *getNonCopyableDerivedPtr() { return nullptr; }

template <typename T>
struct FieldInAnonStruct {
FieldInAnonStruct() : field(5) {}
FieldInAnonStruct(const FieldInAnonStruct &) = delete;
FieldInAnonStruct(FieldInAnonStruct &&) = default;
struct {
T field;
};
};

using FieldInAnonStructNC = FieldInAnonStruct<NonCopyable>;

#endif // TEST_INTEROP_CXX_CLASS_MOVE_ONLY_VT_H
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ MoveOnlyCxxValueType.test("Test move only field access in derived holder") {
expectEqual(c.x.x, 5)
}

MoveOnlyCxxValueType.test("Test move only field in anonymous struct") {
let a = FieldInAnonStructNC()
let b = a
}
runAllTests()