mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Much of IRGen is built around fields (example: enum packing/unpacking). This is a simpler/less bug-prone way to do it.
62 lines
1.0 KiB
C++
62 lines
1.0 KiB
C++
struct HasThreeFields {
|
|
int a = 1;
|
|
int b = 2;
|
|
int c = 3;
|
|
};
|
|
|
|
struct DerivedWithOneField : HasThreeFields {
|
|
int d = 4;
|
|
};
|
|
|
|
struct HasOneField {
|
|
int e = 5;
|
|
};
|
|
|
|
struct DerivedFromAll : HasOneField, DerivedWithOneField {
|
|
int f = 6;
|
|
};
|
|
|
|
struct OneField {
|
|
int value = 42;
|
|
};
|
|
|
|
struct DerivedFromOneField : OneField {};
|
|
|
|
// Non trivial types:
|
|
|
|
struct __attribute__((swift_attr("import_unsafe"))) NonTrivial {
|
|
NonTrivial() {}
|
|
~NonTrivial() {}
|
|
};
|
|
|
|
struct NonTrivialHasThreeFields : NonTrivial {
|
|
int a = 1;
|
|
int b = 2;
|
|
int c = 3;
|
|
};
|
|
|
|
struct NonTrivialDerivedWithOneField : NonTrivialHasThreeFields {
|
|
int d = 4;
|
|
};
|
|
|
|
struct __attribute__((swift_attr("import_unsafe"))) NonTrivialHasOneField {
|
|
NonTrivialHasOneField() {}
|
|
~NonTrivialHasOneField() {}
|
|
|
|
int e = 5;
|
|
};
|
|
|
|
struct __attribute__((swift_attr("import_unsafe"))) NonTrivialDerivedFromAll
|
|
: NonTrivialHasOneField,
|
|
NonTrivialDerivedWithOneField {
|
|
int f = 6;
|
|
};
|
|
|
|
// Templates:
|
|
|
|
template<class T>
|
|
struct ClassTemplate {
|
|
T value;
|
|
};
|
|
|
|
struct DerivedFromClassTemplate : ClassTemplate<int> {}; |