CharUnits AlignedNextFieldOffsetInChars =
NextFieldOffsetInChars.RoundUpToAlignment(FieldAlignment);
+ if (AlignedNextFieldOffsetInChars > FieldOffsetInChars) {
+ assert(!Packed && "Alignment is wrong even with a packed struct!");
+
+ // Convert the struct to a packed struct.
+ ConvertStructToPacked();
+
+ AlignedNextFieldOffsetInChars = NextFieldOffsetInChars;
+ }
+
if (AlignedNextFieldOffsetInChars < FieldOffsetInChars) {
// We need to append padding.
AppendPadding(FieldOffsetInChars - NextFieldOffsetInChars);
assert(NextFieldOffsetInChars == FieldOffsetInChars &&
"Did not add enough padding!");
- AlignedNextFieldOffsetInChars =
- NextFieldOffsetInChars.RoundUpToAlignment(FieldAlignment);
- }
-
- if (AlignedNextFieldOffsetInChars > FieldOffsetInChars) {
- assert(!Packed && "Alignment is wrong even with a packed struct!");
-
- // Convert the struct to a packed struct.
- ConvertStructToPacked();
-
AlignedNextFieldOffsetInChars = NextFieldOffsetInChars;
}
static int b[1] = { "asdf" }; // expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char [5]'}}
static int c[1] = { L"a" };
}
-
-// PR21300
-void g30() {
-#pragma pack(1)
- static struct {
- int : 1;
- int x;
- } a = {};
- // CHECK: @g30.a = internal global %struct.anon.1 <{ i8 undef, i32 0 }>, align 1
-#pragma pack()
-}