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 {
31123112 }
31133113 }
31143114 }
3115- if (copyCtor && !isExplicitlyNonCopyable) {
3115+ if (copyCtor && !isExplicitlyNonCopyable &&
3116+ !decl->isAnonymousStructOrUnion ()) {
31163117 clangSema.DefineImplicitCopyConstructor (clang::SourceLocation (),
31173118 copyCtor);
31183119 }
3119- if (moveCtor) {
3120+ if (moveCtor && !decl-> isAnonymousStructOrUnion () ) {
31203121 clangSema.DefineImplicitMoveConstructor (clang::SourceLocation (),
31213122 moveCtor);
31223123 }
Original file line number Diff line number Diff line change @@ -6940,6 +6940,10 @@ namespace {
69406940 }
69416941
69426942 void addValueWitnessTable () {
6943+ if (auto cd = Target->getClangDecl ())
6944+ if (auto rd = dyn_cast<clang::RecordDecl>(cd))
6945+ if (rd->isAnonymousStructOrUnion ())
6946+ return ;
69436947 auto vwtPointer = emitValueWitnessTable (/* relative*/ false ).getValue ();
69446948 B.addSignedPointer (vwtPointer,
69456949 IGM.getOptions ().PointerAuth .ValueWitnessTable ,
Original file line number Diff line number Diff line change @@ -56,4 +56,16 @@ struct NonCopyableHolderDerivedDerived: NonCopyableHolderDerived {
5656inline NonCopyable *getNonCopyablePtr () { return nullptr ; }
5757inline NonCopyableDerived *getNonCopyableDerivedPtr () { return nullptr ; }
5858
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+
5971#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") {
7070 expectEqual ( c. x. x, 5 )
7171}
7272
73+ MoveOnlyCxxValueType . test ( " Test move only field in anonymous struct " ) {
74+ let a = FieldInAnonStructNC ( )
75+ let b = a
76+ }
7377runAllTests ( )
You can’t perform that action at this time.
0 commit comments