Context.getTypeInfoInChars(FD->getType());
if (FD->isBitField() && FD->getMaxAlignment() != 0)
Info.Alignment = std::max(Info.Alignment, FieldRequiredAlignment);
- // Respect pragma pack.
- if (!MaxFieldAlignment.isZero())
- Info.Alignment = std::min(Info.Alignment, MaxFieldAlignment);
}
// Respect packed field attribute.
if (FD->hasAttr<PackedAttr>())
// Capture required alignment as a side-effect.
RequiredAlignment = std::max(RequiredAlignment, FieldRequiredAlignment);
}
+ // Respect pragma pack.
+ if (!MaxFieldAlignment.isZero())
+ Info.Alignment = std::min(Info.Alignment, MaxFieldAlignment);
// TODO: Add a Sema warning that MS ignores bitfield alignment in unions.
if (!(FD->isBitField() && IsUnion))
Alignment = std::max(Alignment, Info.Alignment);
// CHECK: 8 | char b
// CHECK-NEXT: 10 | int c
// CHECK-NEXT: | [sizeof=16, align=4
-// CHECK-NEXT: | nvsize=16, nvalign=4]
+// CHECK-NEXT: | nvsize=14, nvalign=4]
// CHECK-X64: *** Dumping AST Record Layout
// CHECK-X64: *** Dumping AST Record Layout
// CHECK-X64-NEXT: 0 | struct X
// CHECK-X64: 8 | char b
// CHECK-X64-NEXT: 10 | int c
// CHECK-X64-NEXT: | [sizeof=16, align=4
-// CHECK-X64-NEXT: | nvsize=16, nvalign=4]
+// CHECK-X64-NEXT: | nvsize=14, nvalign=4]
struct Y : A, B {
char a;
// CHECK-X64-NEXT: | [sizeof=16, align=16
// CHECK-X64-NEXT: | nvsize=16, nvalign=16]
+#pragma pack()
+struct JA { char a; };
+#pragma pack(1)
+struct JB { __declspec(align(4)) char a; };
+#pragma pack()
+struct JC : JB, JA { };
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK: *** Dumping AST Record Layout
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct JC
+// CHECK-NEXT: 0 | struct JB (base)
+// CHECK-NEXT: 0 | char a
+// CHECK-NEXT: 1 | struct JA (base)
+// CHECK-NEXT: 1 | char a
+// CHECK-NEXT: | [sizeof=4, align=4
+// CHECK-NEXT: | nvsize=4, nvalign=4]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT: 0 | struct JC
+// CHECK-X64-NEXT: 0 | struct JB (base)
+// CHECK-X64-NEXT: 0 | char a
+// CHECK-X64-NEXT: 1 | struct JA (base)
+// CHECK-X64-NEXT: 1 | char a
+// CHECK-X64-NEXT: | [sizeof=4, align=4
+// CHECK-X64-NEXT: | nvsize=4, nvalign=4]
+
int a[
sizeof(X)+
sizeof(Y)+
sizeof(YF)+
sizeof(YF)+
sizeof(D2)+
+sizeof(JC)+
0];