Skip to content

Commit 090e849

Browse files
committed
Add test for memory layout
1 parent eae5817 commit 090e849

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

test/ClangImporter/Inputs/custom-modules/cxx_interop.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ int PrivateFunction() __attribute__((swift_private));
3939

4040
class PrivateClass {} __attribute__((swift_private));
4141

42+
class ClassWithImportedField {
43+
public:
44+
int field;
45+
};
46+
47+
class ClassWithUnimportedField {
48+
public:
49+
int field __attribute__((swift_private));
50+
};
51+
4252
class Methods2 {
4353
public:
4454
int SimpleMethod(int);

test/ClangImporter/cxx_interop.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ func unimportedSwiftPrivateFunction() {
3434

3535
func unimportedSwiftPrivateClass() {
3636
_ = PrivateClass() // expected-error {{cannot find 'PrivateClass' in scope}}
37-
}
37+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift -Xfrontend -cxx-interoperability-mode=default -I %S/Inputs/custom-modules %s -o %t/a.out
3+
// RUN: %target-run %t/a.out
4+
5+
import CXXInterop
6+
7+
assert(MemoryLayout<ClassWithImportedField>.size == MemoryLayout<ClassWithUnimportedField>.size,
8+
"ClassWithImportedField and ClassWithUnimportedField should have the same size.")

0 commit comments

Comments
 (0)