Files
swift-mirror/test/Interop/Cxx/class/Inputs/member-variables.h
Gabor Horvath 998591e9f9 [cxx-interop] Do not import zero-sized fields
Zero sized fields are messing up the offset calculations when we import
C++ fields to Swift. We assume that the size of the field is determined
by the type of the field. This is not true for fields marked with
no_unique_address. Those fields can have 0 size while the
sizeof(decltype(field)) is still 1.

rdar://143907490
2025-02-03 11:55:54 +00:00

32 lines
597 B
C++

#ifndef TEST_INTEROP_CXX_CLASS_INPUTS_MEMBER_VARIABLES_H
#define TEST_INTEROP_CXX_CLASS_INPUTS_MEMBER_VARIABLES_H
class MyClass {
public:
const int const_member = 23;
};
struct Empty {
using type = int;
int getNum() const { return 42; }
};
struct HasZeroSizedField {
int a;
[[no_unique_address]] Empty b;
short c;
[[no_unique_address]] Empty d;
int* e;
[[no_unique_address]] Empty f;
int get_a() const { return a; }
short get_c() const { return c; }
void set_c(short c) { this->c = c; }
};
inline int takesZeroSizedInCpp(HasZeroSizedField x) {
return x.a;
}
#endif