[clang] [Clang][Windows] Preserve x86_fp80 and vector alignment under #pragma pack. (PR #208256)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 16 08:28:50 PDT 2026
================
@@ -2539,9 +2548,22 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
const ASTRecordLayout &Layout = getASTRecordLayout(RD);
Width = toBits(Layout.getSize());
Align = toBits(Layout.getAlignment());
- AlignRequirement = RD->hasAttr<AlignedAttr>()
- ? AlignRequirementKind::RequiredByRecord
- : AlignRequirementKind::None;
+ // Check if the record has an aligned attribute, or if it contains
+ // fields with ABI-required alignment (e.g., x86_fp80).
+ if (RD->hasAttr<AlignedAttr>()) {
+ AlignRequirement = AlignRequirementKind::RequiredByRecord;
+ } else {
+ // Check if any field has RequiredByABI alignment requirement.
+ // If so, propagate it to the record.
----------------
zahiraam wrote:
Testing shows this isn't the case for nested structs under `#pragma pack`. I added a test in the LIT test to show that. The test cases demonstrate that both explicit (`alignas`) and implicit `(x86_fp80`) alignment requirements need this propagation to work correctly through nesting.
https://github.com/llvm/llvm-project/pull/208256
More information about the cfe-commits
mailing list