Files
clang-p2996/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
Michael Buch 46e848a23b [lldb][test] Add test-cases for packed/aligned structures (#96932)
Adds test that checks whether LLDB correctly infers the
alignment of packed structures. Specifically, the
`InferAlignment` code-path of the `ItaniumRecordLayoutBuilder`
where it assumes that overlapping field offsets imply a
packed structure and thus sets alignment to `1`. See discussion
in https://github.com/llvm/llvm-project/pull/93809.

While here, also added a test-case where we check alignment of
a class whose base has an explicit `DW_AT_alignment
(those don't get transitively propagated in DWARF, but don't seem
like a problem for LLDB).

Lastly, also added an XFAIL-ed tests where the aforementioned
`InferAlignment` kicks in for overlapping fields (but in this
case incorrectly since the structure isn't actually packed).
2024-06-28 14:15:09 +01:00

24 lines
312 B
C++

struct B1 {
char f1;
};
struct alignas(8) B2 {
char f2;
};
struct D : B1, B2 {};
D d3g;
struct alignas(8) EmptyClassAlign8 {
} t;
struct alignas(8) __attribute__((packed)) AlignedAndPackedBase {
} foo;
struct Derived : AlignedAndPackedBase {
} bar;
static_assert(alignof(Derived) == 8);
int main() {}