@@ -131,6 +131,33 @@ public:
131131 inline ClassWithNoThrowingConstructor ( ) noexcept { }
132132} ;
133133
134+ struct StructWithDefaultConstructor {
135+ StructWithDefaultConstructor ( ) = default;
136+
137+ int m = 0 ;
138+ } ;
139+
140+
141+ struct NonTrivial {
142+ ~ NonTrivial( ) { }
143+ } ;
144+
145+ struct StructWithDefaultCopyConstructor {
146+ StructWithDefaultCopyConstructor ( ) noexcept { }
147+ StructWithDefaultCopyConstructor ( const StructWithDefaultCopyConstruct or & ) = default;
148+
149+ int m = 0 ;
150+ NonTrivial _nonTrivialPoison ;
151+ } ;
152+
153+ struct StructWithDefaultDestructor {
154+ StructWithDefaultDestructor ( ) noexcept { }
155+ ~ StructWithDefaultDestructor( ) = default;
156+
157+ int m = 0 ;
158+ NonTrivial _nonTrivialPoison ;
159+ } ;
160+
134161//--- test.swift
135162
136163import CxxModule
@@ -227,6 +254,22 @@ func testClassWithNoThrowingConstructor() -> CInt {
227254 return obj. m
228255}
229256
257+ func testStructWithDefaultConstructor( ) -> StructWithDefaultConstructor {
258+ return StructWithDefaultConstructor ( )
259+ }
260+
261+ func testStructWithDefaultCopyConstructor( ) -> CInt {
262+ var s = StructWithDefaultCopyConstructor ( )
263+ let copy = s
264+ return s. m
265+ }
266+
267+ func testStructWithDefaultDestructor( ) -> CInt {
268+ let s = StructWithDefaultDestructor ( )
269+ let result = s. m
270+ return result
271+ }
272+
230273let _ = testFreeFunctionNoThrowOnly ( )
231274let _ = testFreeFunctionCalls ( )
232275let _ = testMethodCalls ( )
@@ -241,6 +284,9 @@ let _ = testClassWithCopyConstructor()
241284let _ = testClassWithThrowingCopyConstructor ( )
242285let _ = testClassWithThrowingConstructor ( )
243286let _ = testClassWithNoThrowingConstructor ( )
287+ let _ = testStructWithDefaultConstructor ( )
288+ let _ = testStructWithDefaultCopyConstructor ( )
289+ let _ = testStructWithDefaultDestructor ( )
244290
245291// CHECK: define {{.*}} @"$s4test0A23FreeFunctionNoThrowOnlys5Int32VyF"() #[[#SWIFTMETA:]] {
246292// CHECK-NEXT: :
@@ -393,6 +439,18 @@ let _ = testClassWithNoThrowingConstructor()
393439// CHECK-NOT: invoke
394440// CHECK: }
395441
442+ // CHECK: define {{.*}} @"$s4test0A28StructWithDefaultConstructorSo0bcdE0VyF"() #[[#SWIFTMETA]] {
443+ // CHECK-NOT: invoke
444+ // CHECK: }
445+
446+ // CHECK: define {{.*}} @"$s4test0A32StructWithDefaultCopyConstructors5Int32VyF"() #[[#SWIFTMETA]] {
447+ // CHECK-NOT: invoke
448+ // CHECK: }
449+
450+ // CHECK: define {{.*}} @"$s4test0A27StructWithDefaultDestructors5Int32VyF"() #[[#SWIFTMETA]] {
451+ // CHECK-NOT: invoke
452+ // CHECK: }
453+
396454// CHECK: i32 @__gxx_personality_v0(...)
397455
398456// CHECK: attributes #[[#SWIFTMETA]] = {
0 commit comments