File tree Expand file tree Collapse file tree 4 files changed +23
-2
lines changed
test/Interop/Cxx/class/move-only Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -3112,11 +3112,12 @@ namespace {
3112
3112
}
3113
3113
}
3114
3114
}
3115
- if (copyCtor && !isExplicitlyNonCopyable) {
3115
+ if (copyCtor && !isExplicitlyNonCopyable &&
3116
+ !decl->isAnonymousStructOrUnion ()) {
3116
3117
clangSema.DefineImplicitCopyConstructor (clang::SourceLocation (),
3117
3118
copyCtor);
3118
3119
}
3119
- if (moveCtor) {
3120
+ if (moveCtor && !decl-> isAnonymousStructOrUnion () ) {
3120
3121
clangSema.DefineImplicitMoveConstructor (clang::SourceLocation (),
3121
3122
moveCtor);
3122
3123
}
Original file line number Diff line number Diff line change @@ -6940,6 +6940,10 @@ namespace {
6940
6940
}
6941
6941
6942
6942
void addValueWitnessTable () {
6943
+ if (auto cd = Target->getClangDecl ())
6944
+ if (auto rd = dyn_cast<clang::RecordDecl>(cd))
6945
+ if (rd->isAnonymousStructOrUnion ())
6946
+ return ;
6943
6947
auto vwtPointer = emitValueWitnessTable (/* relative*/ false ).getValue ();
6944
6948
B.addSignedPointer (vwtPointer,
6945
6949
IGM.getOptions ().PointerAuth .ValueWitnessTable ,
Original file line number Diff line number Diff line change @@ -56,4 +56,16 @@ struct NonCopyableHolderDerivedDerived: NonCopyableHolderDerived {
56
56
inline NonCopyable *getNonCopyablePtr () { return nullptr ; }
57
57
inline NonCopyableDerived *getNonCopyableDerivedPtr () { return nullptr ; }
58
58
59
+ template <typename T>
60
+ struct FieldInAnonStruct {
61
+ FieldInAnonStruct () : field(5 ) {}
62
+ FieldInAnonStruct (const FieldInAnonStruct &) = delete ;
63
+ FieldInAnonStruct (FieldInAnonStruct &&) = default ;
64
+ struct {
65
+ T field;
66
+ };
67
+ };
68
+
69
+ using FieldInAnonStructNC = FieldInAnonStruct<NonCopyable>;
70
+
59
71
#endif // TEST_INTEROP_CXX_CLASS_MOVE_ONLY_VT_H
Original file line number Diff line number Diff line change @@ -70,4 +70,8 @@ MoveOnlyCxxValueType.test("Test move only field access in derived holder") {
70
70
expectEqual ( c. x. x, 5 )
71
71
}
72
72
73
+ MoveOnlyCxxValueType . test ( " Test move only field in anonymous struct " ) {
74
+ let a = FieldInAnonStructNC ( )
75
+ let b = a
76
+ }
73
77
runAllTests ( )
You can’t perform that action at this time.
0 commit comments